Spreadsheet Practice

How to calculate years of service in Excel

Formula (Excel and Google Sheets)

=DATEDIF(B2,$F$1,"y")&" years, "&DATEDIF(B2,$F$1,"ym")&" months"

Use =DATEDIF(hire_date, as_of, "y")&" years, "&DATEDIF(hire_date, as_of, "ym")&" months" for completed years and months.

Result on the example
one result per row in C2, filled down to C6
Works in
Every current version
Google Sheets
Same formula

See it work

The formula is already in C2, filled down to C6. Change any input and the result updates, or edit the formula to experiment.

How it works

DATEDIF counts complete units: "y" gives the whole years since the hire date and "ym" the whole months after the last work anniversary. S. Novak was hired on December 31, 2001, so on December 31, 2026 the service is exactly 25 years.

=DATEDIF(B2,$F$1,"y")&" years, "&DATEDIF(B2,$F$1,"ym")&" months"

Result"15 years, 9 months"

  1. B23/14/2011

    The value in B2.

  2. $F$112/31/2026

    The value in F1.

  3. DATEDIF(B2,$F$1,"y")15

    DATEDIF: Difference in "Y", "M", "D", "YM", "MD" or "YD".

    • start_dateB23/14/2011
    • end_date$F$112/31/2026
    • unit"y"
  4. DATEDIF(B2,$F$1,"y")&" years, ""15 years, "

    The & operator joins as text.

  5. DATEDIF(B2,$F$1,"ym")9

    DATEDIF: Difference in "Y", "M", "D", "YM", "MD" or "YD".

    • start_dateB23/14/2011
    • end_date$F$112/31/2026
    • unit"ym"
  6. DATEDIF(B2,$F$1,"y")&" years, "&DATEDIF(B2,$F$1,"ym")"15 years, 9"

    The & operator joins as text.

  7. DATEDIF(B2,$F$1,"y")&" years, "&DATEDIF(B2,$F$1,"ym")&" months""15 years, 9 months"

    The & operator joins as text.

In Google Sheets

The same formula works in Google Sheets: =DATEDIF(B2,$F$1,"y")&" years, "&DATEDIF(B2,$F$1,"ym")&" months". We ran it in Google Sheets mode on the same data and it returns the same results.

Other ways to do it

Each one was run on the same example sheet.

FormulaResultWhen to use it
=DATEDIF(B2,$F$1,"y")15, 7, 2…Different resultWhole years only, for service awards or PTO tiers. Completed years as a number.
=ROUNDDOWN(($F$1-B2)/365.25,1)15.8, 7.4, 2.9…Different resultDecimal years like 15.8, close enough for a report. YEARFRAC is the exact function for this. Approximate decimal years.

Common mistakes

  • YEAR(F1)-YEAR(B2) counts calendar years, not service: someone hired on December 31 would show a full year on January 1.
  • Keep the as-of date in a cell. With TODAY() inside the formula, last year's report changes every time you open it.
  • A hire date stored as text returns #VALUE!. Convert it first.

Try it yourself

Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.

Calculate years of service

In C2, show each employee's service on the date in F1 as "15 years, 9 months", and fill down to C6.

Questions

How do I calculate service in years with decimals?

YEARFRAC returns fractional years: =YEARFRAC(B2,$F$1) gives about 15.8 for R. Alvarez.

How do I find who reaches 10 years this year?

Check the year of the 10-year anniversary: =YEAR(EDATE(B2,120))=YEAR($F$1).

Checked by running on 2026-10-30: every formula and result on this page was calculated by the Spreadsheet Practice formula engine, in both Excel and Google Sheets modes.