Mile-O
Back once again...
- Local time
- Today, 12:23
- Joined
- Dec 10, 2002
- Messages
- 11,316
Copy the following function into a new module:
With this function you can calculate a person's age properly. It can also work two ways:
For these 2 options, call the function like so:
Code:
Public Function Age(dteDOB As Date, Optional SpecDate As Variant) As Integer
Dim dteBase As Date, intCurrent As Date, intEstAge As Integer
If IsMissing(SpecDate) Then
dteBase = Date
Else
dteBase = SpecDate
End If
intEstAge = DateDiff("yyyy", dteDOB, dteBase)
intCurrent = DateSerial(Year(dteBase), Month(dteDOB), Day(dteDOB))
Age = intEstAge + (dteBase < intCurrent)
End Function
With this function you can calculate a person's age properly. It can also work two ways:
- Calculate a person's age as at today
- Calculate a person's age as at a specific date
For these 2 options, call the function like so:
- Age([DOB])
- Age([DOB], [SpecificDate])