Two Date Difference in Excel: How to Calculate Days
In this article
To find the difference between two dates in Excel, the fastest method is to subtract the start date from the end date using a simple subtraction formula (e.g., =B1-A1). Because Excel stores dates as sequential serial numbers, subtracting one from another yields the exact number of days between them. This approach works for basic day counts, while more complex requirements—such as calculating only business days or breaking the difference down into years, months, and days—require specialized functions like DATEDIF or NETWORKDAYS.
What You'll Need
- Microsoft Excel (any version, including Office 365, Excel 2021, 2019, or Excel Online).
- A dataset containing at least two columns of dates.
- Dates entered in a format that Excel recognizes as a date (e.g., MM/DD/YYYY or DD-MMM-YYYY) rather than as plain text.
Step-by-Step
- Prepare Your Data: Enter your start date in one cell (for example, cell A2) and your end date in another cell (for example, cell B2). Ensure that the end date is chronologically after the start date to avoid getting a negative number.
- Insert the Subtraction Formula: Click on the cell where you want the result to appear (cell C2). Type the equals sign
=to start the formula, then click on the cell containing the end date, type a minus sign-, and click on the cell containing the start date. Your formula should look like=B2-A2. - Press Enter: Once you hit Enter, Excel will calculate the difference. If the result looks like another date (e.g., January 5, 1900) instead of a number, you must change the cell formatting.
- Format the Result as a Number: Select the cell with the result. Go to the Home tab on the ribbon. In the Number group, click the dropdown menu (which likely says "Date") and select General or Number. This converts the serial date back into a count of days.
- Calculate Working Days Only: If you need to exclude weekends and holidays, use the NETWORKDAYS function. In a new cell, type
=NETWORKDAYS(A2, B2). This function automatically removes Saturdays and Sundays. To exclude specific holidays, list those holiday dates in a separate range (e.g., E2:E10) and update the formula to=NETWORKDAYS(A2, B2, E2:E10). - Calculate Difference in Months or Years: For more granular control, use the DATEDIF function. Note that DATEDIF is a "hidden" function and will not appear in the formula autocomplete list, but it works in all versions. Type
=DATEDIF(A2, B2, "d")for days,=DATEDIF(A2, B2, "m")for full months, or=DATEDIF(A2, B2, "y")for full years. - Drag the Fill Handle: To apply the calculation to an entire column, hover your mouse over the bottom-right corner of the result cell until a small black cross appears. Click and drag the handle down to fill the formula for all remaining rows.
Common Mistakes
One of the most frequent errors is the "Date Format Trap." When you subtract two dates, Excel sometimes assumes the result should also be a date because the source cells were dates. This leads to a result like "January 15, 1900" instead of "15." Always remember to change the result cell format to "General" or "Number" to see the actual day count.
Another common mistake is entering dates as text. If you type a date as "12th of Jan 2023," Excel treats it as a string of words, not a numerical value. When you try to subtract text, Excel returns a #VALUE! error. To check if your date is valid, look at the alignment; by default, Excel aligns numbers and dates to the right of the cell and text to the left.
Users also frequently swap the start and end dates in the formula. If you use =Start_Date - End_Date, you will get a negative number. While mathematically correct, it often breaks other formulas or looks incorrect in reports. Always subtract the earlier date from the later date.
Tips
To make your spreadsheets more dynamic, use the TODAY() function. If you want to calculate how many days have passed from a specific date until right now, use the formula =TODAY()-A2. This will update automatically every time you open the file, which is ideal for tracking project deadlines or aging invoices.
If you need to calculate a difference that includes a fraction of a day (time), ensure your cells are formatted as "Date and Time." The subtraction method still works, but the result will be a decimal. For example, a result of 1.5 means one full day and 12 hours have passed. You can use the INT() function to strip the decimals if you only care about the whole days.
For complex reporting, combine DATEDIF functions to get a human-readable string. For example, using =DATEDIF(A2, B2, "y") & " Years, " & DATEDIF(A2, B2, "ym") & " Months" will output a result like "2 Years, 3 Months," which is far more useful for HR records or age calculations than a raw number of days.
Troubleshooting
If your formula returns a #VALUE! error, the most likely cause is that one of your dates is not actually a date in Excel's eyes. To fix this, select the date column, go to the Data tab, select Text to Columns, click Next twice to get to Step 3, select Date from the column data format dropdown, and click Finish. This forces Excel to re-evaluate the text as dates.
If you see a series of hashtags (#######) in the cell, it usually means the column is too narrow to display the result, or the result is a negative date. Excel cannot display negative dates in the standard date format. Check your formula to ensure the end date comes first, or change the cell format to "General."
If the NETWORKDAYS function is giving you a number that seems slightly off, check your regional settings. By default, NETWORKDAYS assumes Saturday and Sunday are the weekend. If you are in a region where the weekend falls on Friday and Saturday, use the NETWORKDAYS.INTL function instead, which allows you to specify which days constitute the weekend using a numeric code.
Frequently Asked Questions
Why is my result showing as a date instead of a number?
Excel automatically applies the formatting of the source cells to the result cell. Since you used dates in your formula, Excel formats the answer as a date. Change the cell format to "General" or "Number" via the Home tab to see the number of days.
How do I exclude holidays from my date difference?
Use the =NETWORKDAYS(start_date, end_date, [holidays]) formula. Create a list of holiday dates in a separate range and reference that range in the third part of the formula to ensure those days aren't counted.
Can I calculate the difference between two dates in hours?
Yes. Subtract the dates as usual (=B2-A2) and then multiply the result by 24. Ensure the result cell is formatted as a "Number" to see the total hours.
What is the difference between subtraction and DATEDIF?
Simple subtraction always gives you the total number of days. DATEDIF is more versatile, allowing you to specifically extract only the number of full years or full months that have elapsed, ignoring the remaining days.
Does the order of dates matter in the formula?
Yes. For basic subtraction and DATEDIF, the start date must come first, followed by the end date. If you reverse them, you will either get a negative number or a #NUM! error.