Smart Systems for Home

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

How Many Days Excel Formula: DATEDIF & NETWORKDAYS

· 5 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

The quickest way to count days between two dates in Excel is the DATEDIF function: =DATEDIF(start_date, end_date, "d"). This returns the total number of full days. For working days only (Monday–Friday), use =NETWORKDAYS(start_date, end_date). This guide covers both formulas, plus variations for excluding holidays, counting from today, and handling blank cells.

What You'll Need

  • Microsoft Excel 2010 or later (the steps work the same in Excel for Microsoft 365, Excel 2021, 2019, and 2016).
  • Two cells containing dates, or one date cell and the TODAY() function.
  • Optional: a list of holiday dates in a separate range if you want to exclude them.

Step-by-Step

  1. Identify your start and end dates. For example, put a start date in cell A1 (e.g., 2024-01-01) and an end date in cell B1 (e.g., 2024-01-10).
  2. Type the DATEDIF formula. In an empty cell, enter =DATEDIF(A1, B1, "d"). Press Enter. The result is the number of full days between the two dates. In this example, it returns 9.
  3. Understand the DATEDIF arguments. The first argument is the start date, the second is the end date, and the third is the unit. Use "d" for days, "m" for complete months, "y" for complete years, "ym" for months remaining after full years, "yd" for days remaining after full years, and "md" for days remaining after full months.
  4. Count days from today. To count days from a past date to today, use =DATEDIF(A1, TODAY(), "d"). To count days from today to a future date, reverse the order: =DATEDIF(TODAY(), A1, "d"). Note that DATEDIF returns an error if the start date is later than the end date.
  5. Use NETWORKDAYS for working days. In a new cell, enter =NETWORKDAYS(A1, B1). This counts Monday through Friday, excluding weekends (Saturday and Sunday). In the example, it returns 8 (Jan 1 is a Monday in 2024, and there are two weekends in that range).
  6. Exclude holidays. If you have a list of holiday dates in cells D1:D3, modify the NETWORKDAYS formula to =NETWORKDAYS(A1, B1, D1:D3). The third argument is optional and can be a range of dates to exclude.
  7. Handle blank cells. If your start or end date might be blank, wrap the formula in an IF statement: =IF(OR(A1="", B1=""), "", DATEDIF(A1, B1, "d")). This returns an empty string instead of an error.
  8. Calculate days in a month. To find the number of days in a given month (say, month in cell A1 as a date), use =DAY(EOMONTH(A1, 0)). This returns 28, 29, 30, or 31.
  9. Use the DAYS function (alternative). Excel also has a DAYS function: =DAYS(end_date, start_date). Note the order is reversed compared to DATEDIF. DAYS is simpler but does not handle units other than days.
  10. Format the result. The result is a number. If you see a date instead, right-click the cell, choose Format Cells, and select Number or General.

Common Mistakes

  • Reversing the arguments. DATEDIF requires start date first, then end date. If you swap them, you get a #NUM! error.
  • Using DAYS with the wrong order. DAYS takes end date first, then start date. If you use =DAYS(A1, B1) with A1 as start, you get a negative number.
  • Forgetting to exclude holidays. NETWORKDAYS without the holiday range counts weekends only, not public holidays.
  • Assuming NETWORKDAYS includes weekends. It does not. If you need all days, use DATEDIF.
  • Typing dates as text. If you type dates in quotes like "2024-01-01", Excel may treat them as text. Use date cells or the DATE function: =DATE(2024,1,1).
  • Not accounting for blank cells. DATEDIF with a blank cell returns #VALUE! or 0. Use IF to handle blanks.

Tips

  • Use named ranges for holidays. If you have a holiday list, name it (e.g., Holidays) and use =NETWORKDAYS(A1, B1, Holidays) for readability.
  • Combine with conditional formatting. Highlight dates that are overdue by comparing =DATEDIF(A1, TODAY(), "d") to a threshold.
  • For age in years, use =DATEDIF(birthdate, TODAY(), "y"). This gives the completed years.
  • Use NETWORKDAYS.INTL for custom weekends. For example, to count Sunday as the only weekend day, use =NETWORKDAYS.INTL(A1, B1, 11) (11 means Sunday only). The weekend codes are numbers: 1 for Sat/Sun, 2 for Sun/Mon, etc.
  • Check your system date settings. If dates appear as text or wrong numbers, go to File > Options > Advanced and ensure the 1900 date system is selected.

Troubleshooting

If DATEDIF returns #NUM!: This usually means your start date is later than your end date. Swap the arguments or use an IF to check: =IF(A1>B1, "Start after end", DATEDIF(A1, B1, "d")).

If NETWORKDAYS returns #VALUE!: Check that your holiday range contains valid dates. If a holiday cell is blank, it is ignored, but if it contains text, it will cause an error. Remove any non-date entries.

If the result is a date (like 1/9/1900): The cell is formatted as a date. Select the cell, go to the Home tab, and change the number format to General or Number.

If the formula does not calculate: Press F9 to recalculate, or check if automatic calculation is off (Formulas > Calculation Options).

If you get a #NAME? error: You likely misspelled the function name. Double-check that you typed DATEDIF or NETWORKDAYS correctly.

Frequently Asked Questions

How do I count days including the start date?

DATEDIF counts full days between dates, so it excludes the start date. To include it, add 1: =DATEDIF(A1, B1, "d") + 1.

Can I count days in a month automatically?

Yes, use =DAY(EOMONTH(A1, 0)) where A1 is any date in that month. It returns the last day of the month, which equals the number of days.

What is the difference between DATEDIF and DAYS?

DAYS is simpler and returns the same result as DATEDIF with "d" but has reversed arguments. DATEDIF also supports months and years. DAYS is available in Excel 2013 and later.

How do I count business days excluding holidays?

Use =NETWORKDAYS(start, end, holidays). The holidays argument is a range of dates to exclude. If you need custom weekends, use NETWORKDAYS.INTL.

Why is my DATEDIF formula not showing a result?

Check that both cells contain actual dates, not text. Also, ensure the end date is not earlier than the start date. If either cell is blank, the formula returns 0 or an error; use IF to handle blanks.

Can I count days from a date to today automatically?

Yes, use =DATEDIF(A1, TODAY(), "d") for past dates. For future dates, use =DATEDIF(TODAY(), A1, "d"). The result updates daily.