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.
Age in whole years from a birthday in B2:
=DATEDIF(B2, TODAY(), "Y")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.
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.
Related functions
More ways Google Sheets gets this done.
- DATEConverts a provided year, month, and day into a date.DateExcel
- DATEVALUEConverts a provided date string in a known format to a date value.DateExcel
- DAYReturns the day of the month that a specific date falls on, in numeric format.DateExcel
- DAYSReturns the number of days between two dates.DateExcel
- DAYS360Returns the difference between two days based on the 360 day year used in some financial interest calculations.DateExcel
- EDATEReturns a date a specified number of months before or after another date.DateExcel