Paul Rodgers
Paul.Rogers at SummitMedia.co.uk
Thu Jul 29 08:47:08 CDT 2004
Thanks, Douglas, appreciated very much. -----Original Message----- From: Gustav Brock [mailto:gustav at cactus.dk] Sent: Wednesday, July 28, 2004 2:30 PM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Dividing days into years and months 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 -- _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com