Link to home
Start Free TrialLog in
Avatar of mig1980
mig1980

asked on

SQL Query question

Good day. I am trying to use the following to find the Age as of a specific date (11/1/12). It doesn't seem to work for all. On some, the age does match what it should be but on some it adds an extra year.

DOB field contains dates as "1997-06-06 00:00:00.000"

The query is CAST(Round((DateDiff(d,id.DOB,'2012-11-01')/365.25),0)  as INT) as AGE

For instance, I have one record where the DOB field is "1995-05-01 00:00:00.000" and the Age comes out as 18 but should be 17.

Any idea how I can get it so that it provides the proper age as of the date requested?
ASKER CERTIFIED SOLUTION
Avatar of appari
appari
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mig1980
mig1980

ASKER

Perfect. Thank you very much!!