Calculation of Age From db2 Table in format MM/DD/YYYY
Posted on 2004-04-13
I need help in calculating an age from a db2 table.
The age from the table is in the format: MM/DD/YYYY.
Are there any db2 functions that could help me calculate this number?
I would need to get the current date and subtract the field in the database; but would I have to parse out the mm,dd, and yyyy fields?
For example, in testing a birth_date of 11/15/1809,
I tried db2 "select current date - date(birth_date) from tablename where birth_date = '11/15/1809'"
but this returns the date in a format of 1940428.
which is the number of years followed by the number of days, I think.
Is there an easier way to perform this calculation?
Thanks In Advance.