Contact

DATEDIF Function in Google Sheets: Syntax, Examples & Compatibility

Date & Time Intermediate Google Sheets

Learn how to measure completed years or days between two dates without counting partial anniversaries as full years in Google Sheets. Includes syntax, two verified-by-reasoning results, troubleshooting and portability notes.

Verification status: See the evidence and test scope described in this guide. How formula examples are checked

Quick answer: DATEDIF(start_date,end_date,unit) measures completed date units. "Y" counts complete years and "M" complete months; neither is a subtraction of displayed year or month labels. Google documents six units, including residual-month and residual-day calculations.

Availability and version history

  • Introduced: Introduction version not established by the official history reviewed.
  • Availability: Documented in the rolling Google Sheets service; examples use the web spreadsheet workflow.
  • Checked: October 14, 2026; official DATEDIF reference. Documentation check, not a new native test; existing example-verification notes retain their scope.

Syntax and documented units

=DATEDIF(start_date, end_date, unit)

Use valid date cells, DATE expressions or appropriate numeric date values. The required unit is quoted text:

Unit Meaning
“Y” Whole years
“M” Whole months
“D” Elapsed days
“YM” Whole months after removing whole years
“MD” Days after removing whole months
“YD” Day difference with the dates treated as no more than one year apart

Keep the output formatted as a number. A count accidentally displayed with a date format can look like an unrelated early historical date.

Two original worked controls

=DATEDIF(DATE(2020,1,1),DATE(2025,1,1),"Y")
=DATEDIF(DATE(2025,1,10),DATE(2025,2,9),"D")

Expected results are 5 complete years and 30 elapsed days. These fixed DATE inputs make the controls reproducible without a changing TODAY value or ambiguous regional date strings.

The second result does not mean one complete month: February 9 is still before the February 10 monthly anniversary of January 10.

Advanced example: test either side of an anniversary

With a start date of June 15, 2020:

End date Expected “Y” result
2026-06-14 5
2026-06-15 6
2026-06-16 6

For example:

=DATEDIF(DATE(2020,6,15),DATE(2026,6,14),"Y")

The expected 5 differs from the simple year-label subtraction 2026−2020, which is 6. The day and month still matter when counting completed anniversaries.

These are ordinary-date controls. A policy for birthdays on February 29 needs its own explicit convention and additional native checks.

Advanced example: distinguish elapsed days from whole months

Use January 15, 2026 as the fixed start:

End date Whole months “M” Elapsed days “D”
2026-02-14 0 30
2026-02-15 1 31
2026-03-15 2 59

Thirty elapsed days do not automatically constitute one complete calendar month. Dividing elapsed days by 30 is a different approximation and does not reproduce these anniversary rules.

For a numeric month count, use the “M” output directly. Appending a unit label is a presentation choice, rather than a reason to replace the numeric result with a locale-dependent date format.

Google-specific short-month example

Google explicitly states that September 30, 2015 to February 28, 2016 contains 4 whole months, even though February 28 is near that month’s end. Its rule requires reaching or passing the start day-of-month.

=DATEDIF(DATE(2015,9,30),DATE(2016,2,28),"M")

Expected documented result: 4. Moving the endpoint to February 29 still has not reached a day numbered 30; the independently modeled whole-month count remains 4. March 1 gives 5, and March 30 gives 6 under the stated day-of-month rule.

This is not a last-day-of-month anniversary policy. If an agreement treats every month end as equivalent, document and implement that policy separately rather than assuming DATEDIF does it.

Advanced example: build an ordinary-date age breakdown

Put =DATE(2020,5,15) in A2 and =DATE(2026,8,20) in B2. In separate numeric cells:

=DATEDIF(A2,B2,"Y")
=DATEDIF(A2,B2,"YM")
=DATEDIF(A2,B2,"MD")

Expected outputs are 6 years, 3 months and 5 days. The total whole-month count =DATEDIF(A2,B2,"M") is 75, not 3. The “YM” component deliberately removes the six complete years.

For these same ordinary dates, =DATEDIF(A2,B2,"YD") gives an expected 97 days since May 15 in the endpoint year: 31 days to June 15, 30 to July 15, 31 to August 15 and five more.

Do not add the numeric components 6+3+5 and call the result elapsed days. The components have different units.

Product-specific residual units and held cases

Google’s reference directly recommends “MD”, “YM” and “YD” for residual age questions. A warning documented for Microsoft’s implementation is not evidence of the same defect in Google Sheets. This guide therefore uses Google’s stated semantics while keeping the worked breakdown away from disputed leap-day and month-end combinations.

The reference does not give a complete error-code table for reversed dates, invalid unit strings, malformed text or out-of-range serials. Keep chronological input order and validate uncertain cases before relying on them. No general equivalence to Excel’s DATEDIF implementation or to legal anniversary rules is certified.

YEAR in Google Sheets · YEAR in Microsoft Excel · DATE in Google Sheets · DATE in Microsoft Excel · NETWORKDAYS in Google Sheets · NETWORKDAYS in Microsoft Excel · Compare DATEDIF in Microsoft Excel

A guide for another spreadsheet is a separate product reference. It does not establish identical date parsing, serial boundaries or error displays after a file import.

The complete guide and original examples were reviewed on October 14, 2026 against direct Google documentation. Calendar, interval and numeric expectations were independently calculated; no native Google Sheets execution, mobile-client certification or complete input-conversion test was performed.