How to Calculate Date Difference in Excel

Two dates in two cells, and a third cell that just needs to show "how many days apart." It looks like a one-key answer, until =B2-A2 comes back showing another date like 1/17/1900 instead of a number, or the count includes weekends that shouldn't count toward a deadline, or a delivery SLA report quietly includes the two public holidays that fell in between.

Excel actually handles date differences well once you know which formula fits the question you're asking — total calendar days, workdays only, or a full years/months/days breakdown. This guide covers each one, the mistakes that break them, and which to use when.

Quick Answer

The simplest way to find the difference between two dates in Excel is direct subtraction, =B2-A2, which returns the number of calendar days as long as the result cell is formatted as a number. To count only workdays, use =NETWORKDAYS(A2,B2), which automatically excludes weekends and, optionally, a list of holiday dates.

What is a date difference formula, and what are the options?

"Date difference" can mean three different things depending on what the spreadsheet needs to answer, and Excel has a separate tool for each one.

All three read the same two date cells; the difference is entirely in how the result gets expressed and which days get counted along the way.

Why the right formula matters

Picking the wrong formula for the question doesn't throw an error — it just quietly gives a technically-correct number that answers something else. That shows up in a few common places:

📊 Quick stat Subtracting two dates directly typically overstates the "working time" between them by roughly two-sevenths, since it counts every weekend day along with the weekdays — a gap that only NETWORKDAYS closes automatically.

Step-by-step: calculating date differences in Excel

Method 1: Total calendar days (direct subtraction)

  1. Enter both dates in separate cells. Make sure both are stored as real dates, not text — for example, A2 as the start date and B2 as the end date.
  2. Click an empty cell for the result. This is where the day count will appear.
  3. Type the subtraction formula.
    =B2-A2
  4. Format the result cell as Number. If the cell shows a date instead of a count, change its format to Number or General so it displays the day total correctly.

Method 2: Workdays only (NETWORKDAYS)

  1. Use NETWORKDAYS with the start and end dates.
    =NETWORKDAYS(A2,B2)
  2. Add a holiday range if needed. A third, optional argument excludes specific dates, such as public holidays, from the count as well.
    =NETWORKDAYS(A2,B2,D2:D10)
  3. Press Enter. The result is the number of working days between the two dates, weekends and listed holidays excluded.

Method 3: Difference in years, months, and days

  1. Use three DATEDIF calls in one formula, changing only the last argument for years, months, and days.
    =DATEDIF(A2,B2,"Y")&" years, "&DATEDIF(A2,B2,"YM")&" months, "&DATEDIF(A2,B2,"MD")&" days"
  2. Press Enter. The formula concatenates all three results into a readable duration, like "1 year, 4 months, 12 days."
Just need one date gap, not a spreadsheet? Rebrixe's free Date Difference Calculator gives the exact result instantly, no formulas required.
Calculate Difference →

Common mistakes with date difference formulas

1. Forgetting to reformat the result cell

Subtracting two dates often inherits Date formatting from one of the source cells, so Excel displays the day count as a date serial, like 1/17/1900, instead of a plain number such as 17.

2. Using subtraction when only workdays should count

=B2-A2 counts every day in between, weekends included, which overstates a deadline, SLA, or timesheet calculation that's actually meant to track business days only.

3. Storing one of the dates as text

A date typed or imported in a format Excel doesn't recognize is stored as text, and both subtraction and NETWORKDAYS return a #VALUE! error against a text cell instead of calculating a difference.

4. Reversing the start and end dates

Putting the later date first returns a negative number from subtraction, and it returns a #NUM! error from DATEDIF, since DATEDIF expects the earlier date as its first argument.

💡 Pro tip If a date-difference result shows small green error triangles or left-aligns instead of right-aligning, one of the source cells is almost always stored as text — reformat it as Date, or wrap it in DATEVALUE(), before running the formula again.

Real-world formula examples

A few common scenarios and the formula each one needs.

Invoice due date
Total calendar days remaining
=B2-TODAY()
Returns the number of calendar days left before a due date, formatted as Number.
Project timeline
Workdays between start and finish
=NETWORKDAYS(A2,B2)
Counts only business days, automatically skipping weekends between two milestone dates.
Employee tenure
Years, months, and days
Y + YM + MD combined
Concatenates three DATEDIF results into a readable duration string for HR reports.
Custom holiday list
Workdays excluding holidays
=NETWORKDAYS(A2,B2,D2:D10)
Excludes a specific range of holiday dates in addition to weekends from the count.

Subtraction vs NETWORKDAYS vs DATEDIF

A side-by-side look at how the three approaches compare in Excel.

Factor Direct subtraction NETWORKDAYS DATEDIF
Output Total calendar days Working days only Years, months, or days
Excludes weekends No Yes No
Can exclude holidays No Yes, optional argument No
Best for Contract terms, invoice due dates SLAs, payroll, project workdays Tenure, age, human-readable durations

Skip the spreadsheet: free date difference calculator

If you just need the gap between two dates and don't want to open Excel, the Rebrixe Date Difference Calculator works entirely in your browser: enter a start and end date, get the exact difference in days, weeks, months, or years instantly. No formulas, no account, no data sent anywhere.

Free Date Difference Calculator Enter two dates, get the exact gap instantly.
Open Date Calculator →

Frequently asked questions

Subtracting the earlier date from the later date, like =B2-A2, returns the number of calendar days between them, as long as both cells are stored as real dates and the result cell is formatted as a number rather than a date.
NETWORKDAYS counts the whole days between a start and end date while automatically skipping Saturdays and Sundays, and NETWORKDAYS.INTL lets you also define a custom weekend pattern or holiday list.
This happens when the result cell inherited Date formatting from one of the source cells, so Excel displays the day count as if it were a date serial number; changing the cell format to Number or General fixes it.
Combine three DATEDIF calls in one formula, one with the "Y" unit for full years, one with "YM" for the remaining months, and one with "MD" for the remaining days, then join the results into a single text string.
A negative result usually means the earlier date was entered after the later date in the formula, and an error usually means one of the two cells is stored as text rather than an actual date value.
Yes. Add a third argument to NETWORKDAYS pointing to a range of holiday dates, and Excel will exclude both weekends and those specific dates from the count.
If both cells include a time component, subtracting them and multiplying the result by 24 converts the fractional day difference into total hours.

Get the exact date gap in seconds

Skip the formulas entirely — the Rebrixe Date Difference Calculator handles weekends, leap years, and month lengths automatically, no spreadsheet required.

Launch the Date Calculator → Launch the Date Calculator →
← Back to blogs