Oracle date difference to get number of years

The Solution to Oracle date difference to get number of years is


I'd use months_between, possibly combined with floor:

select floor(months_between(date '2012-10-10', date '2011-10-10') /12) from dual;

select floor(months_between(date '2012-10-9' , date '2011-10-10') /12) from dual;

floor makes sure you get down-rounded years. If you want the fractional parts, you obviously want to not use floor.

~ Answered on 2011-10-30 05:16:45


Most Viewed Questions: