Subtracting Dates in Excel: Simple Methods and Formulas
In this article
To subtract dates in Excel, simply subtract the start date cell from the end date cell using a minus sign (e.g., =B2-A2). This works because Excel stores dates as sequential serial numbers, where each whole number represents one full day starting from January 1, 1900. By subtracting one date from another, Excel calculates the exact number of days between those two points in time.
What You'll Need
- Microsoft Excel (any version, including Excel for the Web).
- A dataset containing at least two columns of dates.
- Cells formatted as "Date" for the inputs and "General" or "Number" for the result.
Step-by-Step
- Enter Your Dates: Input your start date in one cell (for example, cell A2) and your end date in another cell (for example, cell B2). Ensure you use a date format that Excel recognizes, such as MM/DD/YYYY or DD-MMM-YYYY.
- Select the Result Cell: Click on the empty cell where you want the difference to appear (for example, cell C2).
- Enter the Subtraction Formula: Type the equals sign
=to start the formula, click on the cell containing the end date (B2), type the minus sign-, and then click on the cell containing the start date (A2). Your final formula should look like=B2-A2. - Press Enter: Hit the Enter key on your keyboard. Excel will now calculate the number of days between the two dates.
- Format the Result: If the result appears as another date (e.g., January 5, 1900) instead of a number, you must change the cell format. Go to the Home tab, locate the Number group in the ribbon, and click the dropdown menu. Select General or Number. This converts the serial date back into a count of days.
- Apply to Multiple Rows: If you have a long list of dates, hover your mouse over the bottom-right corner of the result cell (C2) until the cursor turns into a small black cross (the fill handle). Click and drag the handle down to the bottom of your data range to copy the formula to all other rows.
Common Mistakes
One of the most frequent errors is incorrect cell ordering. In Excel, subtracting a later date from an earlier date results in a negative number. For example, if you subtract today's date from a date last year, you will get a negative integer. Always follow the logic of End Date - Start Date = Duration to ensure a positive result.
Another common mistake is mixing data types. Sometimes dates are entered as text rather than actual date values. If a date is left-aligned in a cell by default, Excel likely perceives it as text. When you try to subtract text, Excel will return a #VALUE! error because it cannot perform mathematical operations on strings of words or non-standard date formats.
Users also frequently forget to change the cell formatting of the result. Because the formula involves date cells, Excel often tries to be helpful by automatically formatting the result cell as a date. This leads to confusing results where a 10-day difference is displayed as "January 10, 1900." Remember that the result of a date subtraction is a quantity of days, not a calendar date, and thus requires a numeric format.
Tips
For more complex calculations, such as finding the number of working days (excluding weekends and holidays), use the NETWORKDAYS function. The syntax is =NETWORKDAYS(start_date, end_date, [holidays]). This is essential for business payroll or project management where weekends should not be counted as elapsed time.
If you need to calculate the difference in specific units like months or years rather than just days, the DATEDIF function is the most powerful tool. While it is a "hidden" function (it won't appear in the formula autocomplete list), it works perfectly. Use =DATEDIF(start_date, end_date, "y") for years, "m" for months, and "d" for days. This is particularly useful for calculating ages or tenure.
To make your spreadsheet more dynamic, you can use the TODAY() function as one of your dates. For example, =TODAY()-A2 will calculate how many days have passed from a specific start date in cell A2 up until the current day. This formula will automatically update every time you open the workbook.
Troubleshooting
If you see a #VALUE! error: This almost always means one of your dates is not being recognized as a number. Check for leading spaces, trailing spaces, or non-standard separators (like using dots instead of slashes). To fix this, you can use the Text to Columns feature under the Data tab to convert the column to a proper Date format.
If the result is a date like 01/05/1900: This is a formatting issue, not a formula error. Right-click the cell, select Format Cells, and under the Number tab, choose General. This tells Excel to show the raw number of days instead of converting that number into a calendar date.
If the result is a negative number: Check your formula order. Ensure the later date (the end date) comes first in the subtraction. If you are using a dynamic range and the dates might be in any order, you can wrap your formula in the ABS function, like =ABS(B2-A2), which returns the absolute value and ensures the result is always positive regardless of which date is larger.
If the calculation is off by one day: This depends on whether you want to include the start date in your count. Simple subtraction calculates the difference between two dates. If you need to include both the start and end date as full working days (inclusive counting), you must add 1 to the result: =(B2-A2)+1.
Frequently Asked Questions
Can I subtract dates that include timestamps?
Yes. If your cells contain both date and time (e.g., 01/01/2023 10:00 AM), subtracting them will result in a decimal. The whole number represents the days, and the decimal represents the fraction of a 24-hour day. To get only the whole days, you can use the INT function: =INT(B2-A2).
How do I subtract 30 days from a specific date?
You can subtract a number directly from a date cell. If your date is in cell A2, simply type =A2-30. Excel will treat the number 30 as 30 days and return the date that occurred exactly 30 days prior.
Why does my date subtraction result in a series of hashtags (#######)?
Hashtags usually appear for two reasons: either the column is too narrow to display the result, or the result is a negative date. Since Excel cannot display negative dates in the standard date format, it shows hashtags. Change the cell format to General to see the negative number.
Does this work across different years?
Yes, Excel's serial date system handles leap years and different month lengths automatically. Whether the dates are one day apart or ten years apart, the subtraction formula will provide the correct total number of days.
Can I subtract dates in Excel for Mac?
Yes, the formulas and logic for subtracting dates are identical across Windows, macOS, and the web-based version of Excel.