I'll start by saying that I like the SQL solution provided by Rudy very much.
This function does the same thing for the lazy developers. Or use it in complex queries that might become too complex:
Function dnAgeYears(StartDate, Optional EndDate)
'=========================================================
'Daniel Vlas, June 10, 1999
'=========================================================
'==========================================================
'The function calculates the FULL years elapsed between two dates.
'It can be used to calculate the age of a person, instead of
'DateDiff function
'DatDiff will return 1 if:
'StartDate is Dec 31, 2000 and EndDate is Jan 01, 2001
'Nice, isn't it-especially when you are 1 day old but you want to look older

'===========================================================
On Error GoTo ErrHandler
If IsMissing(EndDate) Then EndDate = Date
If DateValue(Format(StartDate, "dd mmmm" & ", " & Year(EndDate))) > EndDate Then
dnAgeYears = Year(EndDate) - Year(StartDate) - 1
Else
dnAgeYears = Year(EndDate) - Year(StartDate)
End If
ExitHere:
Exit Function
ErrHandler:
'What can be wrong? Bad dates as arguments...
dnAgeYears = "#DatesError"
Resume ExitHere
End Function
HTH
![[pipe] [pipe] [pipe]](/data/assets/smilies/pipe.gif)
Daniel Vlas
Systems Consultant