How to Calculate Years of Service in Excel

If the start date is in B2 and the end date in C2, change only the DATEDIF unit to get years, months or days of service. For current employees, use TODAY() instead of C2.

Formula to use

=DATEDIF(B2, C2, "Y")&" years "&DATEDIF(B2, C2, "YM")&" months"

Length of service, e.g. 5 years 3 months

Service in each unit

"Y" is complete years, "M" is complete months in total and "D" is days. "YM" is the months left after whole years.

  • =DATEDIF(B2, C2, "Y")Years of service
  • =DATEDIF(B2, C2, "M")Total months worked
  • =C2-B2Days between the two dates (same as DAYS(C2, B2))

The date of a work anniversary

EDATE moves a date forward or back by a number of months. Twelve months later is the first anniversary. If the result shows as a number, apply a date format.

  • =EDATE(B2, 12)1st anniversary
  • =EDATE(B2, 12*10)10th anniversary

Common mistakes

Microsoft notes that the "MD" unit (days left after months) can give inaccurate results, so use another method if you need the days as well.

If your policy counts the last day as a working day, add a day with C2+1. Check your company's rules.

Try the functions used here

Change the arguments in the function playground and watch the calculation step by step.

  • DATEDIF functionCounts the complete years, months or days between two dates. Use it for ages and lengths of service.
  • EDATE functionReturns the same day a number of months later (or earlier).
  • DAYS functionReturns the number of days between two dates (end_date - start_date).
  • TODAY functionReturns today's date. It updates every time the file recalculates.

FAQ

How do I get years of service as a decimal (5.3 years)?
Divide the months by 12, as in =DATEDIF(B2,C2,"M")/12, and set the decimals with ROUND.
How do I use today when the end date is blank?
Choose the end date with IF: =DATEDIF(B2, IF(C2="", TODAY(), C2), "Y").

More guides