Forum Discussion
Service time
hyview I assume you want the total number of years, months and days rather than a long text string that merely returns the years, months and days for each period.
To do that you could do something like this (Excel 365 or 2021):
=LET(
y_1, DATEDIF(AA22,AB22,"Y"),
m_1, DATEDIF(AA22,AB22,"YM"),
d_1, DATEDIF(AA22,AB22,"MD"),
y_2, DATEDIF(AC22,AD22,"Y"),
m_2, DATEDIF(AC22,AD22,"YM"),
d_2, DATEDIF(AC22,AD22,"MD"),
TEXTJOIN(" ",,y_1+y_2, "Years",m_1+m_2,"Months",d_1+d_2,"Days"))But, that could leave you with a result like this:
Obviously, that's nonsense as 16 months by itself translates to 1 year and 4 months. And 42 days equals 1 month plus 14, 13, 12 or 11 days, So you would want it to show 2 years, 5 months and 11 to 14 days, depending on which months of which years were covered. Probably doable but the formula would become a fair bit longer.
Why not just use this?
=AB22-AA22+AD22-AC22
or
=(AB22-AA22+AD22-AC22)/365.25This will return 892 for the total number of days or 2.44 (rounded to 2 decimals) years. The latter being 2 years and just over 5 months (i.e 0.44 x 12 = 5.28).