[AccessD] Dividing days into years and months

Scott Marcus marcus at tsstech.com
Wed Jul 28 07:09:54 CDT 2004


Here is a function that is approximate. You will need to add code for leap years...

Public Function YMD(ByVal startdate As Date, ByVal enddate As Date)
Dim intYears As Integer
Dim intMonths As Integer
Dim intDays As Integer

intDays = DateDiff("d", startdate, enddate)
intYears = intDays / 365
intMonths = (intDays / 365) * 12 - (intYears * 12)
intDays = intDays - (intYears * 365) - ((intMonths / 12) * 365)
YMD = "Years:" & intYears & " Months:" & intMonths & " Days:" & intDays
End Function




More information about the AccessD mailing list