![]() ![]() See the example below: SELECT TRUNC( MONTHSBETWEEN(SYSDATE,(SYSDATE-600)) /12 ) AS YearsFROM DUAL Now to finding out the difference in years, months and days together will make the query more complicated. Once you got a total number of month convert it to years by dividing it with 12 months. SELECT TRUNC(MONTHSBETWEEN(SYSDATE,(SYSDATE-60))) AS MonthsFROM DUAL To find out date difference in years you would need to convert the number of days in an amount of month. 60 AS SecondsFROM DUAL To finding out the difference in months we will use the function MONTHSBETWEEN that gives us the final result.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |