FormulaCraft

How to calculate the years between two dates in Excel and Google Sheets

Topic:Date arithmetic
Excel & Google Sheets
=DATEDIF(A2,B2,"Y")

Try it with your data

Edit the grid or formula, then run it through a real spreadsheet engine — no signup.

Sample data — click any cell to edit

Runs server-side · free · no signup

Step by step

  1. 1Place the earlier date in A2 and the later date in B2.
  2. 2Enter =DATEDIF(A2,B2,"Y") in the result cell.
  3. 3This returns the number of complete years; partial years are ignored.
  4. 4For fractional years (e.g., 2.75 years), use =YEARFRAC(A2,B2) instead.
  5. 5Press Enter to see the result formatted as a whole number.

Tips

Need it for your exact data?

Describe your columns in plain English and get the precise formula for your sheet, with the right Excel or Sheets syntax.

Frequently asked

Why use DATEDIF instead of just subtracting years: YEAR(B2)-YEAR(A2)?

YEAR(B2)-YEAR(A2) counts any two dates in different years as 1 year apart, even if only a day apart (e.g., Dec 31 and Jan 1). DATEDIF correctly counts only complete 12-month periods.

What is YEARFRAC good for?

YEARFRAC returns a decimal representing the fraction of a year, useful in financial calculations such as interest accrual where you need 1.5 years rather than just 1.

More on Date arithmetic

See all →

Formulas used

Written and reviewed by FormulaCraft Team. Each formula on this page is run through our verification engine before publishing.

Last reviewed: