Days and years between dates: DAYS and DATEDIF

Working with dates · About 6 minutes

Days and years between dates: DAYS and DATEDIF

DAYS counts the days between two dates. The later date goes first: =DAYS(B2,A2) reads as "days from A2 to B2".

DATEDIF counts whole years, months or days. =DATEDIF(B2,TODAY(),"Y") reads as "whole years from B2 until today". The earlier date goes first here, and the unit goes in quotes: "Y" for years, "M" for months, "D" for days.

Whole years matter for age and length of service. Someone born in August 1990 is still 34 in March 2025, even though 2025 minus 1990 is 35.

DATEDIF works in Excel and Google Sheets, but Excel doesn't suggest it as you type, so type its name in full.

Part of Plus

Free during our founding launch: sign in to unlock this lesson's exercises, the timed practice sets and the rest of Plus. The free lessons stay free, with no account needed.

What DATEDIF and DAYS does

DAYS counts the days between two dates. DATEDIF counts whole years, whole months or days between them, and only counts a year once the full year has passed.

That is what you need for an age, years of service or the length of a contract. For an age, give DATEDIF the birth date, then TODAY(), then "Y": someone born in October 1995 is 30 until their birthday in October 2026, even though 2026 minus 1995 is 31.

How to write DATEDIF and DAYS

=DATEDIF(start_date, end_date, unit)

start_date
The earlier date, like the day someone joined.
end_date
The later date, like a review date or TODAY().
unit
What to count, in quotes: "Y" whole years, "M" whole months, "D" days, "YM" months left over after the years, "YD" days left over after the years.

=DAYS(end_date, start_date)

end_date
The later date goes first here, the opposite of DATEDIF.
start_date
The earlier date. The answer is the number of days from this one to the end date.

DATEDIF and DAYS worked example

Reviews are on September 1, 2026. In D2, find how many whole years Rosa has been on the team, then fill down to D4.

Reviews are on September 1, 2026. In D2, find how many whole years Rosa has been on the team, then fill down to D4.
ABCD
1NameJoinedReviewYears
2Rosa09/15/201909/01/20266
3Ken03/01/202109/01/20265
4Ada09/01/201609/01/202610
D2=DATEDIF(B2,C2,"Y")Count the whole years from Rosa's start in B2 to the review in C2: 6, because her 7th year is not complete until September 15, 2026.

Common DATEDIF and DAYS mistakes

DATEDIF shows a #NUM! error

The start date is later than the end date. Swap them so the earlier date comes first.

DAYS gives a negative number

The dates are the wrong way round for DAYS. Put the later date first, or take the earlier date from the later one with a minus sign.

The age is one year too high

Taking one YEAR from another ignores whether the birthday has come yet this year. Use DATEDIF with "Y", which only counts full years.

DATEDIF or DAYS?

Use DAYS, or simply the later date minus the earlier one, when you want a count of days. Use DATEDIF when you want whole years or months, like an age or years of service.

DATEDIF works in Excel and Google Sheets. Microsoft keeps it for older workbooks and warns that the "MD" unit can give a wrong answer, so avoid that one.

Questions people ask

How do I calculate age in Excel?

=DATEDIF(B2,TODAY(),"Y") gives whole years from the birth date in B2 until today.

Why isn't DATEDIF in Excel's function list?

Excel keeps it for older files and doesn't suggest it as you type, but it works. Type its name in full.

Which date goes first in DAYS and DATEDIF?

DAYS takes the later date first: =DAYS(B2,A2). DATEDIF takes the earlier date first: =DATEDIF(A2,B2,"D").

Why not just subtract the years?

2025 minus 1990 is 35, but someone born in August 1990 is still 34 in March 2025. DATEDIF counts whole years.

Theme