New: ready-to-use spreadsheet templatesExplore the collection  →
Home/Formulas/DATEDIF
DATE & TIME · GOOGLE SHEETS

DATEDIF
calculate whole days, months or years between dates.

Use DATEDIF to calculate complete months between two dates. This guide shows the exact structure, a working example and the mistakes most likely to break it.

JosephineVerified by JosephineReviewed July 25, 2026
THE FORMULA=DATEDIF(start_date, end_date, unit)
A

start_dateearlier date

B

end_datelater date

C

unitD, M, Y, MD, YM or YD

TRY IT YOURSELF

Change the sheet.
Watch the answer update.

Edit any highlighted cell below. The example recalculates immediately.

LIVE PLAYGROUND=DATEDIF(A2,B2,"M")
fx=DATEDIF(A2,B2,"M")
A · STARTB · END
2
3
4
5
RESULT18 monthsUpdates live

Try changing a value above. This example runs entirely in your browser.

IN PLAIN ENGLISH

How the formula
thinks.

  1. 01

    start_dateearlier date

  2. 02

    end_datelater date

  3. 03

    unitD, M, Y, MD, YM or YD

COMMON FIXES

When DATEDIF
doesn’t behave.

WRONG RESULT

Wrong result

Check that every range starts and ends on the same rows, and that numbers are stored as numbers.

FORMULA PARSE ERROR

Formula parse error

Check commas, quotation marks and closing parentheses. Your locale may use semicolons instead of commas.

UNEXPECTED BLANKS

Unexpected blanks

Test the source cells for hidden spaces, empty strings and inconsistent data types.

fxNeed help with DATEDIF?Fix my formula →