1. ## Age calculation

I am using the following function to work out the age of someone.

DateDiff("yyyy", DOB, Date)

The DateDiff calculation does not look at partial months, ie dob 12/05/90 will produce an age of 11 even though they are only 10. Can anyone help??

2. ## Re: Age calculation

Try this function

Function Age(Bdate, DateToday) As Integer
' Returns the Age in years between 2 dates
' Doesn't handle negative date ranges i.e. Bdate > DateToday

If Month(DateToday) < Month(Bdate) Or (Month(DateToday) = _
Month(Bdate) And Day(DateToday) < Day(Bdate)) Then
Age = Year(DateToday) - Year(Bdate) - 1
Else
Age = Year(DateToday) - Year(Bdate)
End If
End Function

Good luck

Richard Aheron
raheron@hotmail.com
[img]/w3timages/icons/grin.gif[/img]

3. ## Re: Age calculation

i put this code in the oncurrent event
yourTextbox = DateDiff("yyyy", [BirthDate], Now()) + Int(Format(Now(), "mmdd") < Format([BirthDate], "mmdd"))
hope it helps
JerryC

4. ## Re: Age calculation

If you just want an integer value this would give you a pretty good approximation:

int((Date - DOB)/365)

Denny

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•