age today from DOB

Mike Hughes

Registered User.
Local time
Today, 01:07
Joined
Mar 23, 2002
Messages
493
I know todays date and I have the DOB how do I get the age from this information. I tried =NOW()-DOB = AGE and I get something returned like this, 777454.3434. I only want the age today.
 
Perform an Advanced Search on here for this. It has been covered many times.
 
In its crudest form the formula is

Age= Int(DateDiff("d",DOB,Date())/365.25)
 
Age: DateDiff("yyyy",[Date_of_Birth],[Date_Of_Death])+Int(Format([Date_Of_Death],"mmdd")<Format([Date_of_Birth],"mmdd"))
 
Thanks all I just used DateDiff with the DOB and today's date
 
Thanks all I just used DateDiff with the DOB and today's date
So, you don't care that you have someone who's birthday is in June but in January through May you will still be counting them as if they already had their birthday? Same with someone with a birthday of December 31st. On January 1st they would be counted as a year older, even though they have almost a full year to go before they are that age.
 
Back to the drawing board......

In post #4 I gave you the answer (it would create a field in a query - just substitute the Date of Birth Field with your actual name. I did forget to modify it back from what the other user had wanted (the age at death) so this should help:

Age: DateDiff("yyyy",[Date_of_Birth],Date())+Int(Format(Date(),"mmdd")<Format([Date_of_Birth],"mmdd"))
 
The following code gives the accurate Years, Months and Days between two dates.

Today = Date()
Date of Birth = [DOB]

The code can be used in a query or directly in an unbound field in a form.

Code:
Years
IIf([DOB] Is Null,"",DateDiff("yyyy",[DOB],Date())-IIf(Format([DOB],"mmdd")>Format(Date(),"mmdd"),1,0))

Months
IIf([DOB] Is Null,"",IIf(Day([DOB])<=Day(Date()),DateDiff("m",[DOB],Date())-[Years]*12,DateDiff("m",[DOB],Date())-[Years]*12-1))

Days
IIf([DOB] Is Null,"",DateDiff("d",DateAdd("m",[Months],DateAdd("yyyy",[Years],[DOB])),Date()))
 

Users who are viewing this thread

Back
Top Bottom