If you need to find the exact difference between two dates worked out to the number of years and the number of days as separate columns then try the following SQL:

SELECT DOB, DOD, ABS(years) years,
GREATEST(DOB,DOD) – ADD_MONTHS(LEAST(DOB,DOD),ABS(12*years)) days
FROM
(
SELECT DOB,DOD, TRUNC(MONTHS_BETWEEN(DOB,DOD) years
FROM <tablename>
)

How to find the exact difference between dates

Leave a Reply

Your email address will not be published.

− seven = two