Date Calculation (SQL, Oracle 10g)

How to calculate the number of years since the product was manufactured (rounded to 1 decimal point) for products that were made less than five years ago? Thanks.

+4
source share
1 answer

Not in front of the IDE right now, so my syntax may be a little bit, 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) 
+4
source

Source: https://habr.com/ru/post/1304536/


All Articles