FormulaCraft

DATEDIF

DATEDIF computes the difference between a start date and an end date according to a unit code: "Y" for complete years, "M" for complete months, "D" for days, "YM" for months ignoring years, "MD" for days ignoring months and years, and "YD" for days ignoring years. Though undocumented in newer Excel versions, it is widely supported and is the standard way to calculate precise age or tenure.

Topic:Date arithmetic
Excel
=DATEDIF(A2,B2,"Y")
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

How it works

  1. 1Enter the start date as the first argument and the end date as the second (start must be earlier).
  2. 2Choose a unit code: "Y" for full years, "M" for full months, "D" for total days.
  3. 3Combine multiple DATEDIF calls for a full age display: =DATEDIF(A2,TODAY(),"Y")&" yrs "&DATEDIF(A2,TODAY(),"YM")&" mo".

Need a version for your data?

Try: “Calculate each employee's age in complete years from their date of birth

More on Date arithmetic

See all →

Related

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

Last reviewed: