Skip to content

Excel function · Dates

DATEDIF

Counts whole years, months or days between two dates.

What it does

DATEDIF returns the difference between two dates in a unit you choose: "Y" for complete years, "M" for complete months, "D" for days. It is the usual way to work out an age. Excel doesn't suggest it as you type, but it works.

Syntax

=DATEDIF(start_date, end_date, unit)

Arguments in square brackets are optional, and … means you can add more of the same. In this Excel language, arguments are separated by ,

Arguments

start_date
The earlier date, such as a date of birth.
end_date
The later date. It must not be before the start date.
unit
What to count, in quotes: "Y" years, "M" months, "D" days. "YM" gives the months left over after whole years.

Example

Someone born on 15 June 1990: how old are they on 1 March 2026?

ABC
1BornOnAge
21990-06-152026-03-0135

The formula in C2:

=DATEDIF(A2,B2,"Y")

Result: 35

Their 36th birthday is not until June 2026, so on 1 March they have completed 35 years.

Common mistakes

  • Swapping the dates. A start date after the end date gives #NUM!.
  • Writing the unit without quotes. Y on its own is read as a name and fails.
  • Dividing the days by 365 instead. Leap years make that drift, so ages come out wrong near birthdays.

In other Excel languages

Excel translates function names, and in some languages the argument separator too. Type the name your Excel shows.

Excel languageFunction nameSeparator
EnglishDATEDIF,
DeutschDATEDIF;
FrançaisDATEDIF;
Español (España)SIFECHA;
Español (México)SIFECHA,
日本語DATEDIF,
한국어DATEDIF,
繁體中文DATEDIF,
ไทยDATEDIF,
ខ្មែរDATEDIF,
Tiếng ViệtDATEDIF;

Practise it

More from this module

All functions