I am trying to get an age in years and months from a given DOB. Right now, my code looks like this:
COLUMN name FORMAT A25
SELECT sNo, fName||CHR(13)||lName Name, sex, TRUNC((CURRENT_DATE - dob) / 365.24, 1) Age
FROM Staff
WHERE position IN ('Manager', 'Secretary')
ORDER BY age DESC;
And it gives me Age outputs in decimal numbers (such as 58.6) which I understand, but I am needing to convert that .6 into a month somehow.
I am thinking that my method of doing this conversion isn’t the most efficient, but I have been searching for hours for a solution, but to no avail. I’ve seen DATEDIFF, but I keep getting an invalid identifier error when trying to use it.
Any ideas?
How about something like this:
And here is the SQL Fiddle.
And this should get you the days as well: http://sqlfiddle.com/#!4/f3a57/4
Good luck.