Gustav Brock
gustav at cactus.dk
Wed Jul 28 08:30:05 CDT 2004
Hi Douglas > Function Age(Date1 As Date, Date2 As Date) As String > Dim Y As Integer > Dim M As Integer > Dim D As Integer > Dim Temp1 As Date > Temp1 = DateSerial(Year(Date2), Month(Date1), Day(Date1)) > Y = Year(Date2) - Year(Date1) + (Temp1 > Date2) > M = Month(Date2) - Month(Date1) - (12 * (Temp1 > Date2)) > D = Day(Date2) - Day(Date1) > If D < 0 Then > M = M - 1 > D = Day(DateSerial(Year(date2), Month(date2), 0)) + D > End If > Age = Y & " years " & M & " months " & D & " days" > End Function Just for the records - this Age() as well as quite a few other Age-functions will fail for those born on 29. Feb. Look up in the archive "Age Calc - How much have I forgotten" to see a reliable method. /gustav