A family of Microsoft relational database management systems designed for ease of use.
Don't calculate age by division, it's not a reliable method. To return age in years use a function like this:
Public Function GetAge(varDoB As Variant, Optional varAgeAt As Variant) As Variant
If IsMissing(varAgeAt) Then varAgeAt = VBA.Date
GetAge = DateDiff("yyyy", varDoB, varAgeAt) - _
IIf(Format(varAgeAt, "mmdd") < Format(varDoB, "mmdd"), 1, 0)
End Function
To return age in Years:Months use this function:
Public Function GetAgeYearsMonths(varDoB As Variant, Optional varAgeAt As Variant) As Variant
Dim intYears As Integer
Dim intMonths As Integer
If IsMissing(varAgeAt) Or IsNull(varAgeAt) Then varAgeAt = VBA.Date
If Not IsNull(varDoB) Then
intYears = DateDiff("yyyy", varDoB, varAgeAt) - _
IIf(Format(varAgeAt, "mmdd") < Format(varDoB, "mmdd"), 1, 0)
intMonths = DateDiff("m", varDoB, varAgeAt) - (intYears * 12)
If Day(varDoB) > Day(varAgeAt) Then
intMonths = intMonths - 1
End If
GetAgeYearsMonths = intYears & ":" & Format(intMonths, "00")
End If
End Function
In both cases they default to returning the age as of today for the date of birth entered. To return someone's age on a specific date, pass the date into the function as the optional second argument. So you'd use:
=GetAge([dob],[arrdate])