How to calculate length of service?

Good afternoon all,

Hoping to learn how to calculate length of service with the results displayed as either Years/Months/Days or Years/Months

At present, I've tried a few formulae which I've found on the community previously, however there seem to be a few issues with inaccurate results.

This formula seems to produce the closest results to what I would expect to see, however it's appears to be adding a year in which is confusing results in some cases:

=YEAR(TODAY()) - YEAR([Job start date]@row) + " years " + IF(MONTH(TODAY()) - MONTH([Job start date]@row) < 0, 12 + MONTH(TODAY()) - MONTH([Job start date]@row), MONTH(TODAY()) - MONTH([Job start date]@row)) + " months " + IF(DAY(TODAY()) - DAY([Job start date]@row) < 0, 30 + DAY(TODAY()) - DAY([Job start date]@row), DAY(TODAY()) - DAY([Job start date]@row)) + " days"

I've tried to use the formula with a "-1" added in to remove the year, however this is then impacting data elsewhere in the report:

=YEAR(TODAY()) - YEAR([Job start date]@row) -1 + " years " + IF(MONTH(TODAY()) - MONTH([Job start date]@row) < 0, 12 + MONTH(TODAY()) - MONTH([Job start date]@row), MONTH(TODAY()) - MONTH([Job start date]@row)) + " months " + IF(DAY(TODAY()) - DAY([Job start date]@row) < 0, 30 + DAY(TODAY()) - DAY([Job start date]@row), DAY(TODAY()) - DAY([Job start date]@row)) + " days"

I was able to create a formula which worked in Excel, however this won't translate in to SmartSheet from what I understand.

=DATEDIF(D3,TODAY(),"y") & " Years, " & DATEDIF(D3,TODAY(),"ym") & " Months, " & DATEDIF(D3,TODAY(),"md") & " Days"

Please let me know if there's any additional info required - any help is greatly appreciated!

Best Answer

  • Paul Newcome
    Paul Newcome ✭✭✭✭✭✭
    Answer ✓

    Try this:

    =YEAR(TODAY()) - YEAR([Job start date]@row) - IF(DATE(YEAR([Job Start Date]@row), MONTH(TODAY()), DAY(TODAY())) < [Job Start Date]@row, 1, 0) + " years " + IF(MONTH(TODAY()) - MONTH([Job start date]@row) < 0, 12 + MONTH(TODAY()) - MONTH([Job start date]@row), MONTH(TODAY()) - MONTH([Job start date]@row)) + " months " + IF(DAY(TODAY()) - DAY([Job start date]@row) < 0, 30 + DAY(TODAY()) - DAY([Job start date]@row), DAY(TODAY()) - DAY([Job start date]@row)) + " days"

Answers

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!