Share via

Excel Date Calculation

Anonymous
2019-04-20T19:30:58+00:00

Hi... I'm trying to determine how long a person has been active in an organization.  They joined (Date 1), went inactive (Date 2), went active (Date 3), until current (Date 4).  I need it displayed as "X years, Y months".  Using DATEDIF, the best I can get it is 7 years, 14 months.

Date 1 = 11/13/2008

Date 2 = 7/14/2016

Date 3 = 10/5/2018

Date 4 = Now()

Any idea how I can do this?

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
Answer accepted by question author
  1. Anonymous
    2019-04-21T02:49:15+00:00

    Mike:

    Assuming you used DateDif(), the 14months was just because you used the wrong conversion codes on the 2 portions

    Here is the MS support page for DateDif()

    https://support.office.com/en-us/article/DATEDIF-function-25dba1a4-2812-480b-84dd-8b32a451b35c

    It does mention that the function converts day counts.

    ***********************

    I took a roundabout way to get to HansV's formula, in tweaked form.

    First, rather than deal with row/column ids, I named each of the date cells:

    Start1, Endd1, Start2, Endd2 

    I find named ranges and named cells easier to work with in formulas

    (note cannot use End1, because entering end in the name field takes you to the horizontal end of the worksheet, oops, new trick to me)

    In my first round, I calculated the days in the 2 separate ranges, summed them, then converted the total days into YMD

    Next I tried HansV's formula and got the same result. But I just couldn't get my head around his formulation of the Date dif using:  "0,a4-a3+a2-a1". 

    It just didn't make sense to me, "0" as a start date.  Eventually I figured out that in the background the datedif function was calculating days, then using the last parameter to calculate the display, so by calculating the number of days as "end date" for datedif would work.  Personally I still have head space problems so I tweaked it a little: "0,(a4-a3)+(a2-a1)"

    I got the same result.

    So my formula ended up as

    =DATEDIF(0,(endd2-Start2)+(endd1-Start1),"Y")&" year(s) "&DATEDIF(0,(endd2-Start2)+(endd1-Start1),"ym")&" month(s) "&DATEDIF(0,(endd2-Start2)+(endd1-Start1),"md")&" DAY(s)"

    Personally, I find using the brackets around the 2 date ranges easier to relate to, ie:

    (endd2-Start2)+(endd1-Start1)

    Here are my formulas

    Note the cell name displayed

    Here is my example spreadsheet:

    https://1drv.ms/x/s!Am8lVyUzjKfpnw5anhJU1VjmCovv

    HansV

    Just curious, where did you get the idea for using "0" as start date?

    1 person found this answer helpful.
    0 comments No comments
Answer accepted by question author
  1. HansV 462.6K Reputation points MVP Volunteer Moderator
    2019-04-20T19:59:55+00:00

    Let's say the dates are in A1 to A4.

    One option:

    =DATEDIF(0,A4-A3+A2-A1,"y")&" year(s) and "&DATEDIF(0,A4-A3+A2-A1,"ym")&" month(s)"

    1 person found this answer helpful.
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more