+ Reply to Thread
Results 1 to 4 of 4

Trying to get the difference between two dates in years

  1. #1
    Registered User
    Join Date
    03-27-2019
    Location
    Texas
    MS-Off Ver
    Excel 2016
    Posts
    5

    Trying to get the difference between two dates in years

    Hi I am using the DATEDIFF function to try to return a value that would show the years between two dates in years.
    I have two dates, one formatted as "12/31/2018" and the other formatted as "20020823". I am having trouble using these together in the date diff function.
    I am hoping the function can return a value like 16.3 or something close to that.

    I am relatively new to excel and vba so if anyone has any tips or advice on how to do this, I would really appreciate it.
    Thanks!

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,791

    Re: Trying to get the difference between two dates in years

    Do you want VBA or will a formula do? What exactly would 16.3 represent? Is this meant to be a true decimal, or is the .3 exactly three months?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    03-27-2019
    Location
    Texas
    MS-Off Ver
    Excel 2016
    Posts
    5

    Re: Trying to get the difference between two dates in years

    I need the code in vba as it is part of another macro I am working on.
    The 16.3 is the difference in years between 08/23/2018 and 12/31/2018.
    The exact value is something closer to 16.3534 but I just approximated for the sake of simplicity. However I do need a decimal value for my code.
    My main problem is formatting as one date is saved as "20020823" and the other is "12/31/2018".
    If you have any ideas feel free to let me know. Thanks

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,791

    Re: Trying to get the difference between two dates in years

    Not with VBA, sorry, but you really should provide a sample workbook with a selection of representative data for our VBA experts to work with.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Calculating Difference Between Two Dates (over multiple years via months)!
    By andyberger87 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-29-2019, 12:03 AM
  2. Replies: 3
    Last Post: 11-22-2015, 04:52 PM
  3. DATEDIF function to get years difference between 2 dates
    By DTYS in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-11-2015, 11:45 PM
  4. [SOLVED] Difference between two dates in terms of years
    By Alexander_Golinsky in forum Excel General
    Replies: 7
    Last Post: 05-03-2012, 11:58 AM
  5. Replies: 2
    Last Post: 12-01-2005, 01:15 AM
  6. difference between two dates in years, months and days.
    By ruby in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-04-2005, 12:06 PM
  7. [SOLVED] i NEED THE DIFFERENCE OF DATES DOWN TO YEARS...IE 11/1/02-4/16/85.
    By nancelsb in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-14-2005, 06:33 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1