Gustav Brock
gustav at cactus.dk
Fri Aug 1 07:38:22 CDT 2003
Hi Mark You may wish to look up "Age Calc" in the archives around Okt. 2002. Many of the "smart" suggestions will fail for date intervals like: #03/01/1988#, #03/01/2002# is 14 #03/01/1968#, #02/28/2000# is 31 where leap years and dates around 29. Feb. are included. /gustav > I need an age calculation function to calculate current age from birthday. > If the person's 30th birthday is on August 1, I want them to be 29 on > July31st. DateDiff rounds up and makes them 30. I made this function > Public Function CalculateAge(datBirth As Date) As Long > Dim lngNumDays As Long > lngNumDays = DateDiff("d", datBirth, Date) > CalculateAge = Int(lngNumDays / 365.25) > End Function > It works, except when today's date is their birthday. In my example, on > their birthday, the function returns 29. The next day it works. It works > for some years on the birthday and not others. How can I make this > foolproof?