[AccessD] Age calculation

Steve Schapel miscellany at mvps.org
Sat Jun 23 15:57:45 CDT 2007


Hehe.  Answering my own question.  I wouldn't mind $5 for every time I 
have used that expression over the last 12 years, on the assumption that 
I had it licked.

And now I see the obvious - in the case of a 29 February birthday, 
evaluating age on 28 February in a non leap year works correctly, but 
evaluating age on 28 February during a leap year, it gives the wrong figure.

So, I have modified accordingly...

Age: DateDiff("yyyy",[DOB],[DateAt])+(Format([DOB]+(Format([DOB],"mmdd")
=Format([DateAt],"mmdd")="0229"),"mmdd")>Format([DateAt],"mmdd"))

Regards
Steve


Steve Schapel wrote:
> However, I can't find an example where the following does not work 
> correctly.  Can you?
> 
> Age: DateDiff("yyyy",[DOB],[DateAt])+(Format([DOB]+(Format([DOB],"mmdd") 
> ="0229"),"mmdd")>Format([DateAt],"mmdd"))



More information about the AccessD mailing list