Back to functions
Date & Time2026-03-142 related articles

DATEDIF Function in Excel

Calculate the difference between two dates in years, months, days, or combinations of them.

Syntax

DATEDIF(start_date, end_date, unit)

Arguments

start_date

Required

The earlier date in the comparison.

end_date

Required

The later date in the comparison.

unit

Required

The time unit to return, such as Y, M, D, YM, YD, or MD.

What it returns

Returns the date difference in the unit you specify.

What DATEDIF does

DATEDIF measures the gap between two dates. It is especially useful when you need the answer in whole years, whole months, or whole days instead of a simple raw subtraction.

Practical examples

Count full years

=DATEDIF(A2,B2,"Y")

This returns the number of complete years between the two dates.

Split a span into years, months, and days

DATEDIF can also return the leftover months or days after removing full years. That makes it a common choice for age calculations and tenure breakdowns.

Common mistakes and notes

Start date must be earlier

If the dates are reversed, DATEDIF can return errors or unexpected results.

Unit codes are strings

The unit argument must be in quotes, such as "Y" or "D".

Related functions

Related articles

Deep dives, troubleshooting guides, and practical examples that use DATEDIF.

Official documentation