How to Calculate Years of Service in Excel (Easy Formulas)

Sumit Bansal
Written by

Sumit Bansal is the founder of TrumpExcel.com and a 13-time Microsoft Excel MVP. He started this site in 2013 to share his passion for Excel through easy tutorials, tips, and training videos, helping you master Excel, boost productivity, and maybe even enjoy spreadsheets!

Last updated

If you have an employee’s joining date, you can calculate their years of service in Excel with a short formula.

Depending on the report, you may need completed years, decimal years, or a result that includes months and days. In this article, I’ll show you the formula for each result, including one that updates automatically every day.

Follow along with the example file

Calculate Years of Service Excel.xlsx

Download

Choose the Right Years-of-Service Formula

Use the table below to match the result you need with the best Excel approach.

Result You NeedRecommended Approach
Completed years between two datesDATEDIF with “y”
Years of service through the current dateDATEDIF with TODAY
Years and remaining monthsDATEDIF with “y” and “ym”
Years, months, and daysLET with EDATE
Decimal yearsYEARFRAC
Future service anniversary dateEDATE

Calculate Completed Years of Service Using DATEDIF

Use this method when you have both a joining date and an end date, and you only need the number of completed years.

Below I have employee joining and end dates, and I want their completed years of service in column D.

Employee joining dates and end dates with an empty Completed Years column

Enter this formula in cell D2:

=DATEDIF(B2:B6,C2:C6,"y")
DATEDIF formula calculating completed years of service for five employees

The DATEDIF formula measures the gap between the two dates. The “y” argument tells Excel to return only completed years.

In Microsoft 365 and newer versions of Excel that support dynamic arrays, this single formula spills all five results into column D.

Pro Tip: If your Excel version does not spill the results, use =DATEDIF(B2,C2,"y") in D2 and fill it down.

In a newer version, a #SPILL! error can appear if cells below the formula are in the way. Clear those cells so the results can spill.

Spilling formulas cannot be used in an Excel Table’s calculated column, so if your data is in a Table, use the per-row formula above instead.

Important: The DATEDIF function returns #NUM! when the joining date comes after the end date.

Dates stored as text can also cause a #VALUE! error. If you get either error, correct the source dates instead of hiding it.

Calculate Years of Service in Excel Using TODAY

This method is useful for current employees because the result updates on its own as time passes.

Below I have a staff list with joining dates, and I want their completed years of service through today in column C.

Employee joining dates with an empty column for service through today

Enter this formula in cell C2:

=DATEDIF(B2:B6,TODAY(),"y")
DATEDIF with TODAY calculating current completed years of service

The TODAY() formula supplies the current date. The DATEDIF function then counts the completed years from each joining date through today.

The TODAY function is a volatile formula, so Excel recalculates it when the workbook opens or another calculation occurs.

Pro Tip: The TODAY function keeps updating the result, so use a fixed as-of date for a historical report that should not change later.

If your list contains current and former employees, add an End Date column. Leave it blank for anyone who still works at the company.

Use this formula to take the end date from column C when one exists, or use the TODAY function when the cell is blank:

=IF(B2:B6="","",DATEDIF(B2:B6,IF(C2:C6="",TODAY(),C2:C6),"y"))
Formula using an employee end date when present and TODAY when it is blank

This gives you one formula for a mixed employee list without placing the TODAY function in every row.

You can also use the DATEDIF and TODAY functions to calculate the total time elapsed from a past date or calculate age from a date of birth.

Follow along with the example file

Calculate Years of Service Excel.xlsx

Download

Calculate Service in Years and Months

Completed years are often enough for a report, but an employee may want to see the remaining months as well.

Below I have employee joining and end dates, and I want their service in years and months, such as “6 Years 9 Months”, in column D.

Employee joining and end dates with an empty Service Period column

Enter this formula in cell D2:

=DATEDIF(B2:B6,C2:C6,"y")&" Years "&DATEDIF(B2:B6,C2:C6,"ym")&" Months"
DATEDIF formula returning service as completed years and remaining months

The first DATEDIF function returns the completed years. The second uses “ym” to return the months left after those complete years are removed.

The ampersand joins both numbers with the words “Years” and “Months.”

In versions of Excel that support dynamic arrays, this formula spills the results down automatically, so you only need to enter it once.

Pro Tip: To calculate service through today, replace both references to C2:C6 with TODAY().

Calculate Service in Years, Months, and Days

If you need a more detailed service period, you can show the remaining days after the completed years and months.

Below I have employee joining and end dates, and I want the full service period in years, months, and days in column D.

Employee joining and end dates with an empty Detailed Service column

Enter this formula in D2 and fill it down:

=LET(start,B2,finish,C2,n,12*(YEAR(finish)-YEAR(start))+MONTH(finish)-MONTH(start),wholeMonths,n-(EDATE(start,n)>finish),QUOTIENT(wholeMonths,12)&" Years "&MOD(wholeMonths,12)&" Months "&finish-EDATE(start,wholeMonths)&" Days")
LET formula returning service in years, months, and days

The formula first finds the number of completed calendar months and splits that number into years and months.

It then calculates the remaining days from the last monthly anniversary to the end date.

This avoids the DATEDIF function’s “md” argument. Microsoft warns that “md” can return an inaccurate result in some date combinations.

The LET function is available in Microsoft 365, Excel 2024, and Excel 2021.

Enter this formula separately for each row because the EDATE function does not return this calculation as a spilling range.

Calculate Decimal Years of Service Using YEARFRAC

Sometimes you need service expressed as a decimal for a prorated benefit or calculation.

Below I have employee joining and end dates, and I want each service period rounded to two decimal places in column D.

Employee joining and end dates with an empty Decimal Years column

Enter this formula in D2 and fill it down:

=ROUND(YEARFRAC(B2,C2,1),2)
YEARFRAC formula returning years of service rounded to two decimal places

The YEARFRAC function returns the fraction of a year between the start and end dates. The third argument, 1, tells Excel to use the actual number of days in the relevant years.

The ROUND function limits the displayed result to two decimal places. If a later calculation needs the full precision, remove the ROUND function.

The INT function can remove the decimal portion, but the DATEDIF function is clearer when you specifically need completed years.

Calculate a Future Service Anniversary Date Using EDATE

You may also need the date when an employee completes a service milestone, such as 5 or 10 years.

Below I have employee joining dates and milestone years, and I want the anniversary date for each milestone in column D.

Employee joining dates and milestone years with an empty Anniversary Date column

Enter this formula in D2 and fill it down:

=EDATE(B2,C2*12)
EDATE formula calculating future service anniversary dates

The EDATE function moves a date by a specified number of months. Multiplying the milestone years by 12 converts them to the number of months the function needs.

If Excel displays a serial number instead of a date, apply a date format to the result cells.

Important: Check how your organization treats employees hired on February 29 before using a calculated anniversary date. The recognized anniversary can differ in a non-leap year.

I covered the formulas for completed years, decimal years, detailed service periods, and future service anniversaries.

Use a fixed end date for historical reports and TODAY when the result should keep updating. I hope you found this article helpful.

Other Excel Articles You May Also Like:

Sumit Bansal

Sumit Bansal

13x Microsoft Excel MVP

Hey! I'm Sumit Bansal, founder of trumpexcel.com and a Microsoft Excel MVP. I started this site in 2013 because I genuinely love Microsoft Excel (yes, really!) and wanted to share that passion through easy Excel tutorials, tips, and Excel training videos. My goal is straightforward: help you master Excel skills so you can work smarter, boost productivity, and maybe even enjoy spreadsheets along the way!

1 thought on “How to Calculate Years of Service in Excel (Easy Formulas)”

  1. In the examples you have, there are examples with joining dates. But I have birth date, retirement date. In this situation, how can the left of service be taken out?

    Reply

Leave a Comment

Get the FREE 51 Excel Tips Ebook

Enter your details and the free PDF is on its way to your inbox.

Hmm, that didn't go through. Please check your email and try again.

No spam. You'll also get my weekly Excel newsletter. Unsubscribe anytime.

Check your inbox!

The ebook is on its way to your email. It usually lands within a couple of minutes.