JCTDD
asked on
Informix SQL get age from ddmmyyyy field
The code below is not accurate as it only minuses the year
year(today)-year(DOB) as AGE
does anybody know a more accurate way of returing a persons age taking into account the day and month of the year as well?
year(today)-year(DOB) as AGE
does anybody know a more accurate way of returing a persons age taking into account the day and month of the year as well?
ASKER
running 2. Accurate one: in aqua studio I get error:
"Invalid day in date"
do you know what is wrong?
"Invalid day in date"
select year(today) - year(mailing_code) - case when mdy(month(mailing_code),day(mailing_code),year(today)) > today then 1 else 0 end
from table_1
do you know what is wrong?
ASKER
example DOBs from the mailing_code field:
mailing_code
26/03/1941
1/10/1958
21/07/1961
mailing_code
26/03/1941
1/10/1958
21/07/1961
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
select ((today - DOB) / 365.25)::int
2. Accurate one:
select year(today) - year(DOB) - case when mdy(month(DOB),day(DOB),ye