Difference between two dates expressed as years, months, days (in one column)

=IF(DATEDIF(A1, B1, "D")>365, QUOTIENT(DATEDIF(A1, B1, "D"), 365)&" year(s) "&
                          QUOTIENT(MOD(DATEDIF(A1, B1, "D"), 365), 30)&" month(s) "&
                      MOD(QUOTIENT(MOD(DATEDIF(A1, B1, "D"), 365), 30), 30)&" day(s)",
 IF(DATEDIF(A1, B1, "D")>30,  QUOTIENT(DATEDIF(A1, B1, "D"), 30)&" month(s) "&
                                   MOD(DATEDIF(A1, B1, "D"), 30)&" day(s)", 
                                       DATEDIF(A1, B1, "D")&" day(s)"))

0


I will interpret your question as requiring an answer in complete years, complete calendar months and any remaining days. This should be fairly straightforward, except where the month containing the start date has more days then the month before the month containing the end date*.

Example:

Start Date End Date Result
28/1/19    1/3/19   1 month and 1 day
29/1/19    1/3/19   1 month and 1 day
30/1/19    1/3/19   1 month and 1 day
31/1/19    1/3/19   1 month and 1 day

If you accept this, then the following formulas should work:

Year

=datedif(A1,B1,"Y")

Month

=mod(datedif(A1,B1,"m"),12)

Day

=IF(DAY(B1)>=DAY(A1),DAY(B1)-DAY(A1),DAY(EOMONTH(B1,-1))+DAY(B1)-MIN(DAY(A1),DAY(EOMONTH(B1,-1))))

enter image description here

EDIT

*Have checked this on this website and found that it makes the same assumption - you get the same duration (1 month and one day) for 28/1/19 to 1/3/19 as 31/1/19 to 1/3/19 although the total number of days (32 or 29) is different.

Possible workaround is to take the days remaining in the start month

=IF(DAY(B1)>=DAY(A1),DAY(B1)-DAY(A1),DAY(EOMONTH(A1,0))-DAY(A1)+DAY(B1))

which seems to agree with this website

You can also use the MD argument to Datedif:

=datedif(A1,B1,"MD")

But in both Google Sheets and Excel this can produce a negative number as warned in the Excel documentation:

The "MD" argument may result in a negative number, a zero, or an inaccurate result. If you are trying to calculate the remaining days after the last completed month...

enter image description here


=IF(                 DATEDIF(A2, B2, "D")> 365, 
      SPLIT(QUOTIENT(DATEDIF(A2, B2, "D"), 365)&" "&
        QUOTIENT(MOD(DATEDIF(A2, B2, "D"), 365), 30)&" "&
    MOD(QUOTIENT(MOD(DATEDIF(A2, B2, "D"), 365), 30), 30), " "),
 IF(                 DATEDIF(A2, B2, "D")> 30, 
 {"", SPLIT(QUOTIENT(DATEDIF(A2, B2, "D"), 30)&" "&
                 MOD(DATEDIF(A2, B2, "D"), 30), " ")},
            {"", "", DATEDIF(A2, B2, "D")}))

0

demo spreadsheet


This is based on already having a field with days difference, in this case field A1 (eg. converts number of days to YMD)

=FLOOR(A1/365)&"y "&FLOOR((A1-(FLOOR(A1/365)*365))/30)&"m "&CEILING(A1-((FLOOR((A1-(FLOOR(A1/365)*365))/30)*30)+((FLOOR(A1/365))*365)))&"d"

It's based on a simplified 365-day year, 30-day month calculation, so not perfectly accurate - however this seems to be the method others have used. It also rounds the days up to full days for my example - this could be rounded down with FLOOR instead of CEILING

enter image description here