Click here to Skip to main content
15,998,180 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to find the difference between two dates in oracle.i tried this code

SQL
select to_date('1-dec-2001')-
           to_date('26-apr-2001') 
    from dual


but it showing date difference in days..but i want the difference as year so what should i do?
Posted
Updated 1-Mar-12 9:15am
v2

try this
SQL
select to_date (date_field,'YYYY') - to_date(date_field,'YYYY') from dual

or you can convert your query
SQL
select  round((to_date('1-dec-2001') - to_date('26-apr-2001') )/365) from dual
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900