# Thread: Years & Months between dates (2000-sr1)

1. ## Years & Months between dates (2000-sr1)

How can I find how many years and months have passed between two dates such as 01/05/88 and 05/07/2001?

Thanks,

Stan

2. ## Re: Years & Months between dates (2000-sr1)

If you want a formula then these will work if start date is in A1 and end date is in B1:

<pre>=DATEDIF(A1,B1,"m")
=DATEDIF(A1,B1,"y")
</pre>

This will also work:
<pre>=12*(YEAR(B1)-YEAR(A1))+(MONTH(B1)-MONTH(A1))+1
=Year(B1)-Year(A1)
</pre>

If you want VBA code, then try:

<pre>Public Function GetMonths(dStart As Date, dEnd As Date) As Long
GetMonths = DateDiff("m", dStart, dEnd)
End Function

Public Function GetYears(dStart As Date, dEnd As Date) As Long
GetYears = DateDiff("yyyy", dStart, dEnd)
End Function
</pre>

Yes, the DateDif functions are undocumented.

3. ## Re: Years & Months between dates (2000-sr1)

Thank you so much for your help. That was exactly what I needed.

Stan

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•