Days Between Two Dates in Excel (and DATEDIF)
By ExcelReady TeamUpdated 6 min read
The short answer
To count the days between two dates in Excel, subtract the earlier date from the later one: =C2-B2. DAYS does the same with the end date first: =DAYS(C2,B2). For whole months or years, use DATEDIF with the start date first and a unit in quotes, like =DATEDIF(B2,C2,"Y").
Key takeaways
- Later date minus earlier date gives the number of days; add 1 if both the first and last day should count.
- DAYS takes the end date first; DATEDIF takes the start date first.
- DATEDIF units: "Y" whole years, "M" whole months, "D" days, "YM" months left over after the years.
- DATEDIF returns #NUM! when the start date is after the end date.
- If the answer looks like a date, change the cell's format to General or Number.
On this page+
- How do you subtract dates in Excel?
- Does Excel count the first day?
- How to use the DAYS function
- How to use DATEDIF for months and years
- How do you count the days from a date until today?
- Why doesn't Excel suggest DATEDIF?
- Which days between dates Excel formula should you use?
- What are the common mistakes?
- Practise it
The simplest days between dates Excel formula is plain subtraction: the later date minus the earlier date. For the same answer with a function, use DAYS. For whole months or years, such as tenure, use DATEDIF. This guide shows all three on one HR sheet, with the units, the argument order and the errors to watch for.
How do you subtract dates in Excel?#
Excel stores dates as serial numbers that count days, so subtracting two dates gives the number of days between them. Put the later date first:
=C2-B2Here B is the hire date and C is the last review:
| Employee | Hire Date | Last Review | =C2-B2 |
|---|---|---|---|
| Jordan Price | Apr 11, 2016 | Mar 15, 2024 | 2895 |
| Mei Chen | Aug 26, 2019 | Sep 2, 2024 | 1834 |
| Carlos Diaz | Jan 4, 2021 | Jun 28, 2024 | 1271 |
| Samir Patel | Jun 13, 2022 | Dec 9, 2024 | 910 |
If the result looks like a strange date, such as 12/4/1907 (December 4, 1907), Excel has given the cell a date format. Change it to General (Ctrl+Shift+~ on Windows, Control+Shift+~ on a Mac) to see the number of days.
How the dates in B and C are displayed depends on your regional settings, but the subtraction works the same
everywhere. To type a date inside a formula, use DATE, like =C2-DATE(2016,4,11), so it can't be misread.
Does Excel count the first day?#
No. Subtraction counts the days from the start to the end, so Monday to Friday of the same week is 4. If both the first and the last day should count, as in "a booking from the 1st to the 5th is 5 days", add 1:
=C2-B2+1For weeks, divide by 7: =(C2-B2)/7 gives 413.57 weeks for Jordan, and =INT((C2-B2)/7) gives 413 whole weeks.
How to use the DAYS function#
DAYS does the same job as subtraction, with the end date first:
=DAYS(end_date, start_date)
=DAYS(C2,B2)For Jordan, both give 2895. DAYS has one advantage: it can read dates typed as text, like =DAYS("2024-03-15","2016-04-11"),
and still give a number. But text dates depend on your regional settings, so cell references or DATE are safer. If you
get a negative number, the dates are the wrong way round. DAYS needs Excel 2013 or later.
How to use DATEDIF for months and years#
DATEDIF counts complete years, months or days between two dates. The start date comes first, the opposite of DAYS:
=DATEDIF(start_date, end_date, unit)The unit is a code in double quotes:
| Unit | Counts | Jordan (Apr 11, 2016 to Mar 15, 2024) |
|---|---|---|
"Y" | Complete years | 7 |
"M" | Complete months | 95 |
"D" | Days, like subtraction | 2895 |
"YM" | Months left over after the complete years | 11 |
"MD" | Days left over after the complete months | 4 |
"YD" | Days left over after the complete years | 339 |
"Complete" matters. Jordan started on April 11, and his review was on March 15, so his eighth year wasn't finished. He
gets 7, not 8. That's why =YEAR(C2)-YEAR(B2), which gives 8, is the wrong answer for tenure.
Combine units to write tenure as text:
=DATEDIF(B2,C2,"Y")&" yrs, "&DATEDIF(B2,C2,"YM")&" mos"This gives "7 yrs, 11 mos" for Jordan. Microsoft notes that the "MD" unit can give wrong results in some cases, so
avoid it in anything important. For more ways to use these units, see
how to calculate age or years of service, or read the full
DATEDIF function guide.
How do you count the days from a date until today?#
Use TODAY() as the later date. =TODAY()-B2 gives the days since B2, and =B2-TODAY() gives the days left until a
future date in B2, such as a deadline. A negative result means the date has already passed.
TODAY() updates every time the file recalculates, so these answers change each day. That's right for a live tracker, but not for a report you need to check later. See TODAY vs NOW in Excel for the difference between the two.
Why doesn't Excel suggest DATEDIF?#
DATEDIF is an older function that Excel keeps for compatibility with other spreadsheet programs. It works in every current version on Windows and Mac, but it isn't listed in the function suggestions and Excel doesn't show its arguments as you type. Type the whole name and the brackets yourself. If you see #NAME?, check the spelling: it's DATEDIF, with one F.
Which days between dates Excel formula should you use?#
Pick the method by the answer you need:
| You need | Use | Example |
|---|---|---|
| Days, quick and simple | Subtraction | =C2-B2 |
| Days, as a named function | DAYS | =DAYS(C2,B2) |
| Complete months or years | DATEDIF | =DATEDIF(B2,C2,"M") |
| Working days, Monday to Friday | NETWORKDAYS | =NETWORKDAYS(B2,C2) |
| A date a number of months away | EDATE | =EDATE(B2,6) |
Working days need a different function, because subtraction counts weekends too. See NETWORKDAYS and WORKDAY. To move forward by months rather than measure a gap, see EDATE and EOMONTH.
What are the common mistakes?#
| Mistake | What you see | Fix |
|---|---|---|
| Earlier date first in subtraction or DAYS | A negative number | Later date first |
| Later date first in DATEDIF | #NUM! | Start date first |
Unit without quotes: DATEDIF(B2,C2,Y) | #NAME? | "Y" in quotes |
| Result shows as a date | Something like 12/4/1907 | Format as General |
| One date stored as text | #VALUE! | Convert it to a real date |
| TODAY() in a report that must not change | The answer changes daily | Point at a fixed "as of" date cell |
Tenure up to today uses TODAY() as the end date: =DATEDIF(B2,TODAY(),"Y"). That's right for a live HR sheet. For a
report or a test answer that must stay the same, put the date in a cell with DATE and point at that instead. Tenure
questions come up often in HR roles; see the Excel skills HR jobs ask for.
Practise it#
Try the DAYS exercise on this page, then practise days between dates and DATEDIF in a live spreadsheet. You'll subtract dates, use DAYS, count years and months with DATEDIF, and build a "7 yrs, 11 mos" tenure label.
Try it yourself
This is a live spreadsheet. Type the formula in the green cell and press Enter.
How many days passed between Jordan's hire date in B2 and last review in C2? In D2, use DAYS. Put the end date first: =DAYS(C2,B2).
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Days | ||||
| 2 | |||||
| 3 | |||||
| 4 | |||||
| 5 | |||||
| 6 | |||||
| 7 | |||||
| 8 |
Tip: DAYS wants the end date first, then the start date. A negative answer means they are the wrong way round.
Practise this in a lesson
Frequently asked questions
What is the formula for the number of days between two dates in Excel?
Subtract the earlier date from the later one, like =C2-B2. You can also use =DAYS(C2,B2), which puts the end date first.
Does Excel count the start date when counting days?
No. =C2-B2 counts the days from the start to the end, so Monday to Friday is 4. Add 1, as in =C2-B2+1, if both days should count.
Why doesn't DATEDIF appear when I type it in Excel?
DATEDIF is an older function that Excel keeps for compatibility. It works, but Excel doesn't suggest it or show its arguments, so type the whole formula yourself.
Why does DATEDIF give #NUM!?
The start date is later than the end date. Swap the first two arguments so the earlier date comes first.
How do I count only working days between two dates?
Use NETWORKDAYS: =NETWORKDAYS(B2,C2) counts Monday to Friday, including both dates. Add a holiday range as a third argument to skip holidays too.