Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Feb 2001
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.
    Legare Coleman

  3. #3
    New Lounger
    Join Date
    Feb 2001
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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
  •