>Yes, 2006 - 1965 does = 41 BUT his birthday is on Decemeber 12th. The
>calculated age should show 40. All the dates past 7/12/06 show this
>extra year.
Thanks guys, this worked out great! I am a newbie to Access and should
assume most of my problems someone else has already had so I'll look
around more next time.
Thanks again.
> >Yes, 2006 - 1965 does = 41 BUT his birthday is on Decemeber 12th. The
> >calculated age should show 40. All the dates past 7/12/06 show this
[quoted text clipped - 12 lines]
>
> John W. Vinson[MVP]
>> Yes, 2006 - 1965 does = 41 BUT his birthday is on Decemeber 12th. The
>> calculated age should show 40. All the dates past 7/12/06 show this
[quoted text clipped - 3 lines]
> DateDiff("yyyy", #12/31/2005#, #1/1/2006#) it will show one year; if
> you use DateDiff("yyyy", #1/1/2006#, #12/31/2006#) it will show zero.
That's right, but if you use DateDiff("d", ...) it shows *days boundaries*. So if you divide the value of DateDiff counting days, you could divide the result with the number of days in a year, i.e. 365...
But then comes the problem with one leap years each fourth year, so you'll have to divide by 365.25...
Then again, every 100 year is *not* a leap year (i.e. Year mod 100 = 0), but it is if Year mod 400 = 0.
All together, if you divide your DateDiff with the number of days the last 400 years (Days400) and use the integer part of the result, you should be fine (not?):
Days400 = DateDiff("d", DateAdd("yyyy", -400, Date()), Date())/400 = 365.2425
Int(DateDiff("d", #12/4/1965#, #12/3/2006#)/(DateDiff("d", DateAdd("yyyy", -400, Date()), Date())/400)) = 40
Int(DateDiff("d", #12/4/1965#, #12/4/2006#)/(DateDiff("d", DateAdd("yyyy", -400, Date()), Date())/400)) = 41
PerL
John Vinson - 17 Jul 2006 18:14 GMT
>All together, if you divide your DateDiff with the number of days the last 400 years (Days400) and use the integer part of the result, you should be fine (not?):
Why go to all the hassle?
Just subtract one year if the birthday has not yet arrived:
DateDiff("yyyy", [DOB], Date()) - IIF(Format([DOB], "mmdd") >
Format(Date(), "mmdd"), 1, 0)
John W. Vinson[MVP]