Skip to content
Excel

DATEDIF function in Excel

Calculates the number of days, months, or years between two dates. This function is useful in formulas where you need to calculate an age.

=DATEDIF(start_date, end_date, unit)

DATEDIF syntax and parameters

Three arguments, three required.

  • start_dateanyRequired

    A date that represents the first, or starting date of a given period. Dates may be entered as text strings within quotation marks (for example, "2001/1/30"), as serial numbers (for example, 36921, which represents January 30, 2001, if you're using the 1900 date system), or as the results of other formulas or functions (for example, DATEVALUE("2001/1/30")).

  • end_dateanyRequired

    A date that represents the last, or ending, date of the period.

  • unitstringRequired

    The type of information that you want returned, where:Unit****Returns"Y"The number of complete years in the period."M"The number of complete months in the period."D"The number of days in the period."MD"The difference between the days in start_date and end_date. The months and years of the dates are ignored.Important: We don't recommend using the "MD" argument, as there are known limitations with it. See the known issues section below."YM"The difference between the months in start_date and end_date. The days and years of the dates are ignored"YD"The difference between the days of start_date and end_date. The years of the dates are ignored.

DATEDIF examples

Formulas you'll actually reuse.

  1. Age in whole years from a birthday in B2:

    =DATEDIF(B2, TODAY(), "Y")
  2. Tenure spelled out — 15 Jan 2026 to 3 Sep 2026 with the Y, YM and MD units:

    =DATEDIF(A2, B2, "Y") & " years, " & DATEDIF(A2, B2, "YM") & " months, " & DATEDIF(A2, B2, "MD") & " days"

    Result"0 years, 7 months, 19 days"

DATEDIF in Google Sheets

Same name — your formula ports as-is.

Try DATEDIF in the playground

Edit the example — nothing to install.

Preloaded with the DATEDIF formula from Example 1 — change anything and watch it respond.

Loading the editor…

DATEDIF errors

What they mean — and the fixes.

  • #NUM!

    The end date is earlier than the start date, or the unit isn't one of Y, M, D, MD, YM, YD.