Here is a function to determine Age. It accounts for the Birthday and the current date.
Code:
'---------------------------------------------------------------------------------------
' Procedure : Age
' Author : Jack (from awf)
' Date : 06-09-2012
' Purpose : This routine determines the Age of a Person given their DOB.
' It accounts for the birthday this year (whether passed or not). A second parameter
' Specdate allows you to work from a different Date than today's date.
'If SpecDate is missing, the routine defaults to today's date.
'---------------------------------------------------------------------------------------
' Last Modified:
'
' Inputs: N/A
' Dependency: N/A
'--------------------------------------------------------------------------
'
Public Function Age(dteDOB As Date, Optional SpecDate As Variant) As Integer
Dim dteBase As Date, intCurrent As Date, intEstAge As Integer
10 On Error GoTo Age_Error
20 If IsMissing(SpecDate) Then
30 dteBase = Date
40 Else
50 dteBase = SpecDate
60 End If
70 intEstAge = DateDiff("yyyy", dteDOB, dteBase)
80 intCurrent = DateSerial(Year(dteBase), Month(dteDOB), Day(dteDOB))
90 Age = intEstAge + (dteBase < intCurrent)
100 On Error GoTo 0
110 Exit Function
Age_Error:
120 MsgBox "Error " & Err.number & " (" & Err.Description & ") in procedure Age of Module AWF_Related"
End Function