Skip to content
Google Sheets

DATEDIF function in Google Sheets

Calculates the number of days, months, or years between two dates.

=DATEDIF(start_date, end_date, unit)

DATEDIF syntax and parameters

Three arguments, three required.

  • start_dateanyRequired

    The start date to consider in the calculation. Must be a reference to a cell containing a DATE, a function returning a DATE type, or a number.

  • end_dateanyRequired

    The end date to consider in the calculation. Must be a reference to a cell containing a DATE, a function returning a DATE type, or a number.

  • unitstringRequired

    A text abbreviation for unit of time. For example,"M" for month. Accepted values are "Y","M","D" ,"MD","YM","YD". "Y": the number of whole years between start_date and end_date. "M": the number of whole months between start_date and end_date. "D": the number of days between start_date and end_date. "MD": the number of days between start_date and end_date after subtracting whole months. "YM": the number of whole months between start_date and end_date after subtracting whole years. "YD": the number of days between start_date and end_date, assuming start_date and end_date were no more than one year apart.

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 Excel

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.