简体   繁体   中英

Date calculating (SQL, Oracle 10g)

How do I calculate number of years since product was made (rounded to 1 decimal point) for products that were made less than five years ago? Thank you.

Not in front of an IDE right now so my syntax may be a little off but something like this should work (assuming a table named table1 with a field named date1) ...

select round((Months_between(current_date,date1)/12),1) as years 
from table1 where date1 > add_months(current_date,-60)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM