Google-sheets – How to get a difference of “X years, Y months, Z days” between two dates

google sheetsgoogle-sheets-dates

I have two dates: 29/05/2020 and today.

How can I get a date diff of these 2 dates, in a meaningful format such as "Z years, X months, Y days" separating these dates?

Ideally this should also take into account the number of days in each months (for example May has 31 days but June has only 30 days) and an additional requirement: I need to subtract 21 days to this duration, because there were 21 days between these 2 dates that "don't count".

Best Answer

I would suggest that you look into the NETWORKDAYS.INTL function, which allows you to find the difference between two dates accounting for standard, customized weekend days off and for any additional list of holidays or days off. For instance, assuming your past date were in cell A1:

=NETWORKDAYS.INTL(A1,TODAY(),"0000001", DaysOff!A2:A)

The plain-English translation here is "Find the workdays that happened between the two dates, given that every Sunday was a day off and additionally excluding any dates listed in DaysOff!A2:A."

The string "0000001" defines what your regular weekend-days-off are, starting with Monday.

0 = "not counted as a weekly day off" 1 = "counted as a weekly day off"

Then you'd just setup a sheet (I suggest DaysOff! here) where you list any additional holidays and such that should not be counted in the total day count between the dates but which are not regular weekly occurrences.