Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

My age calculation does not work past 1930

Status
Not open for further replies.

Ryker7

MIS
Jun 19, 2003
44
US
I use the following to calculate age based on the birthdate entered on a form

Expr1: IIf(IsNull([Birthdate]),Null,IIf(CDate(Month([birthdate]) & "/" & Day([birthdate]) & "/" & Year(Date()))>Date(),DateDiff("yyyy",[birthdate],Date())-1,DateDiff("yyyy",[birthdate],Date())))

It works fine until a birthday year past 1930 is entered. When the birth year is 1929 it returns -25 as the age. Any suggestions?
 
It seems as if you are working with 2 digit years. The default range for 2 digits is 1930 to 2029, which means that years between 00 and 29 will be 2000 to 2029.


Hope this helps.
 
How are ya Ryker7 . . . . .

Maybe this'll do . . .
Code:
[blue]   Age=DateDiff("yyyy", [Bdate], Now())+ _
            Int( Format(now(), "mmdd") < Format( [Bdate], "mmdd") )[/blue]

Calvin.gif
See Ya! . . . . . .
 
I'm with earthandfire, educate your users to enter non ambiguous dates in [birthdate].
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top