To calculate the number of days between two dates in Excel, use a simple subtraction formula. Excel stores dates as serial numbers, so subtracting one date from another returns the exact number of days between them. No add-ins or special functions are required—this works in all modern versions of Excel on Windows, Mac, or web.
What You'll Need
- A spreadsheet with at least two cells containing valid dates
- Excel installed (desktop, web, or mobile app)
- Basic familiarity with entering formulas in Excel cells
Step-by-Step
- Open your Excel workbook and ensure the two dates you want to compare are in separate cells. For example, enter "1/15/2024" in cell A2 and "3/22/2024" in cell B2. Make sure the cells are formatted as dates—Excel will usually auto-detect this when you type a recognizable date format.
- Click on a blank cell where you want the result to appear, such as C2. This is where the day difference will display.
- Type the formula:
=B2-A2. Do not include quotes. This subtracts the earlier date from the later one. The order matters: always subtract the start date from the end date to get a positive result. - Press Enter. Excel will calculate and display the number of days between the two dates—in this case, 66.
- If the result appears as a date instead of a number, select the cell with the formula, right-click, choose "Format Cells," then select "General" under the Number tab. This ensures the result displays as a whole number, not as a date serial.
- To calculate multiple date pairs, drag the fill handle (small square at the bottom-right corner of the cell with the formula) down to copy the formula to other rows. Excel will automatically adjust the row numbers in the formula (e.g., =B3-A3, =B4-A4, etc.).
- If your dates are in different columns, adjust the cell references accordingly. For example, if your start date is in D5 and end date is in F5, use
=F5-D5.
Common Mistakes
- Subtracting in the wrong order: If you type
=A2-B2when A2 is the earlier date, you’ll get a negative number. Always subtract the earlier date from the later one to avoid confusion. - Using text instead of actual dates: If a cell shows a date but Excel treats it as text (left-aligned instead of right-aligned), the formula will return a #VALUE! error. Check by selecting the cell—look at the formula bar. If the date appears as text like "January 15, 2024" instead of a number, convert it using DATEVALUE or re-enter it as a valid date (e.g., 1/15/2024).
- Formatting the result as a date: If the cell with your formula is formatted as a date, Excel will display the serial number as a date (e.g., 66 becomes 2/5/1900). Always format the result cell as "General" or "Number".
- Including time values without accounting for them: If your dates include time (e.g., 1/15/2024 14:30), Excel still calculates correctly, but the result might show decimals (e.g., 66.43). To get whole days only, wrap the formula in INT():
=INT(B2-A2).
Tips
- Use the TODAY() function to calculate days from today:
=TODAY()-A2gives you how many days have passed since the date in A2. This is useful for tracking deadlines or aging invoices. - For absolute differences (ignoring negative results), use ABS():
=ABS(B2-A2). This ensures the result is always positive, regardless of which date is entered first. - Combine with conditional formatting to highlight dates that are more than 30 days apart: Select your results column, go to Home > Conditional Formatting > New Rule > Use a formula, then enter
=C2>30and choose a highlight color. - For date ranges spanning years, the formula works the same—Excel handles leap years and month lengths automatically.
- To include both start and end dates in the count (e.g., 1/1 to 1/3 = 3 days), add 1 to the formula:
=B2-A2+1.
Troubleshooting
- #VALUE! error: This means one or both cells contain text that Excel can’t interpret as a date. Check the cell formatting. Try typing the date again in a new cell using the format MM/DD/YYYY or DD/MM/YYYY depending on your regional settings. Alternatively, use =DATEVALUE(A2) to convert text to a date, then subtract.
- #REF! error: You’ve referenced a cell that no longer exists, often because you deleted a row or column. Check the formula in the result cell and correct the cell references.
- Result shows as a date: Format the cell as General. Right-click the cell > Format Cells > Number > General > OK.
- Formula doesn’t copy properly: When dragging the fill handle, ensure you’re dragging the cell with the formula, not just the result. If it doesn’t update, check if the cells are locked (Review > Protect Sheet) or if Excel is in manual calculation mode (Formulas > Calculation Options > Automatic).
- Formula returns 0: Verify both cells contain actual dates—not blank cells or identical dates. Use =ISTEXT(A2) or =ISNUMBER(A2) to test if a cell contains a true date value.