Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Days Diff in Excel: Calculate Date Differences

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Yes, Excel can calculate the number of days between two dates, and the simplest way is to subtract the earlier date from the later one in a formula, like =B2-A2. This returns the exact number of days between the two dates. For more complex needs—like counting only business days, or finding days in months or years—Excel has dedicated functions. Here's how to do all of it, step by step.

What You'll Need

  • A computer with Microsoft Excel (2013 or later is fine; the steps work in Excel for Microsoft 365, Excel 2021, 2019, and 2016).
  • Two columns with dates, or you can type dates directly into formulas.
  • Dates must be entered as real Excel dates (e.g., 2025-01-15 or 15-Jan-2025), not as text. If your dates are text, Excel might not calculate correctly—see Troubleshooting below.

Step-by-Step

Method 1: Basic Day Count (Subtraction)

  1. Open your Excel worksheet with two date columns, say Column A (start date) and Column B (end date).
  2. Click on an empty cell where you want the result, for example, C2.
  3. Type the formula: =B2-A2 and press Enter.
  4. Excel will show the number of days between those two dates. If B2 is after A2, the result is positive. If B2 is before A2, the result is negative (which is correct if you need that).
  5. To copy the formula down the column, click the small square at the bottom-right of the cell (the fill handle) and drag it down.
  6. If the result shows as a date (like 1/15/1900) instead of a number, right-click the cell, choose Format Cells, select Number, and set Decimal places to 0. This happens because Excel sometimes inherits the date format from the adjacent cells.

Method 2: Using the DATEDIF Function (For Days, Months, Years)

  1. DATEDIF is a hidden but powerful function. In a cell, type =DATEDIF(start_date, end_date, "d") where "d" stands for days.
  2. Example: =DATEDIF(A2, B2, "d") returns the same as subtraction but only counts complete days. It always returns a positive number if the end date is after the start date, even if you swap the order—it will return an error if the start is after the end.
  3. For months, use "m" (complete months), for years use "y" (complete years). For example, =DATEDIF(A2, B2, "m") gives the number of full months between the dates.
  4. DATEDIF is not listed in the function wizard, so you must type it manually. It works in all modern Excel versions.

Method 3: Counting Business Days (Weekdays Only)

  1. Use the NETWORKDAYS function to count only Monday–Friday days, excluding weekends.
  2. In a cell, type =NETWORKDAYS(start_date, end_date). This includes both the start and end dates in the count.
  3. Example: =NETWORKDAYS(A2, B2) returns the number of working days between those two dates.
  4. To also exclude holidays, add a range of holiday dates. First, list the holiday dates in a column, say E2:E5. Then type =NETWORKDAYS(A2, B2, E2:E5).
  5. If you need to count weekends only, use =NETWORKDAYS.INTL with a weekend parameter, but that's more advanced—stick to NETWORKDAYS for most needs.

Method 4: Days in a Month or Year

  1. To find how many days are in a specific month, use the EOMONTH function. For a date in cell A2, type =DAY(EOMONTH(A2,0)). This returns the last day of the month, and DAY extracts that number (28, 29, 30, or 31).
  2. To find days between two dates in different years, simply subtract as in Method 1—it works across years.
  3. For days remaining in the year from a date, use =DATE(YEAR(A2),12,31)-A2.

Method 5: Using the DAYS Function (Simple)

  1. Excel also has a DAYS function: =DAYS(end_date, start_date). Note the order—end date first.
  2. Example: =DAYS(B2, A2) gives the same result as =B2-A2.
  3. This function is useful if you prefer a named function over subtraction, but it does the same thing.

Common Mistakes

  • Dates as text: If you type dates like "Jan 15, 2025" as text (with a comma), Excel won't recognize them as dates. Always use a format Excel understands, like 2025-01-15 or 15-Jan-2025.
  • Wrong cell format: If the result looks like a date (e.g., 1/15/1900), the cell is formatted as a date. Change it to Number format.
  • Reversed arguments in DATEDIF: DATEDIF requires the start date first, then the end date. If you reverse them, it returns a #NUM! error.
  • Including both endpoints incorrectly: Subtraction =B2-A2 excludes the start day. For example, from Jan 1 to Jan 2 gives 1 day. If you need to count both days, add 1: =B2-A2+1.
  • Using NETWORKDAYS with text holidays: Holiday dates must be real dates, not text, or they will be ignored.

Tips

  • Use absolute references: When copying formulas, use $A$2 if you want to keep a fixed date, like a project start date.
  • Format negative results: If you expect negative days (when the end date is before the start), Excel will show a negative number. You can wrap the formula in =ABS(B2-A2) to get the absolute value.
  • Use TODAY() for dynamic counts: To calculate days from today to a deadline, use =TODAY()-A2 (if A2 is a past date) or =A2-TODAY() for days remaining.
  • Combine with IF for readability: For example, =IF(B2>A2, B2-A2, "Check dates") to flag errors.
  • For large datasets, use a table: Convert your data to an Excel Table (Ctrl+T) so formulas auto-fill as you add rows.

Troubleshooting

If the result is a date, not a number: Select the cell, go to the Home tab, and in the Number group, choose "Number" from the dropdown. Set decimal places to 0.

If you get #VALUE! error: This usually means one of the cells contains text that looks like a date but isn't recognized. Check the cell's format: right-click, Format Cells, and see if it's set to Date. If not, re-enter the date using a slash or dash format.

If you get #NUM! error in DATEDIF: The start date is later than the end date. Swap the arguments or use =IF(A2>B2, "Start after End", DATEDIF(A2,B2,"d")).

If NETWORKDAYS returns 0 or wrong count: Check that your holiday range is correct and that the holiday cells are formatted as dates. Also, ensure the start and end dates are in the correct order (start first).

If the formula doesn't recalculate: Press F9 to force a recalculation, or check if calculation is set to Manual (Formulas tab > Calculation Options).

If you copied the formula and it shows the same result everywhere: Check that the cell references are relative (A2, B2) not absolute ($A$2). If they are absolute, remove the dollar signs.

Frequently Asked Questions

Why does subtracting dates give a number that looks like a date?

Excel stores dates as serial numbers (1 = Jan 1, 1900). When you subtract, the result is a number, but the cell might be formatted as a date. Change the cell format to Number.

How do I count days including both the start and end date?

Add 1 to the subtraction: =B2-A2+1. For example, from Jan 1 to Jan 3 inclusive is 3 days, and =3-1+1 gives 3.

Can I count weekdays excluding holidays?

Yes, use =NETWORKDAYS(start, end, holidays) where holidays is a range of date cells. It excludes weekends and the listed holidays.

What if my dates are in different columns but I want the difference in years?

Use =DATEDIF(start, end, "y") for complete years, or =YEAR(B2)-YEAR(A2) for a rough year difference.

Is there a way to calculate days between two times as well?

Yes, if you have date and time in the same cell (e.g., 2025-01-15 9:00 AM), subtracting gives a decimal number (e.g., 2.5 days). To get whole days, use =INT(B2-A2).

Why does DATEDIF not appear in the function list?

DATEDIF is a legacy function from Lotus 1-2-3 and is not documented in Excel's function wizard, but it still works. Just type it manually.