To subtract dates in Excel, subtract one cell from another with a simple formula like =B2-A2, then format the result as a number to see the difference in days. Excel stores dates as serial numbers, so subtraction returns the number of days between them. If you need months or years instead of days, use the DATEDIF function.
What You'll Need
- Microsoft Excel on Windows, Mac, or the web (the steps below work in all three; button labels can differ slightly by version and platform)
- Two dates entered in separate cells, in a format Excel recognizes (for example,
1/15/2025or15-Jan-2025) - An empty cell for the result
Step-by-Step
- Enter your dates. Type the start date in one cell (say A2) and the end date in another (say B2). Use a format your regional settings recognize. If Excel left-aligns the entry, it may be storing it as text rather than a date.
- Click an empty cell where you want the result to appear, for example C2.
- Type the subtraction formula. Enter
=B2-A2and press Enter. This gives the number of days between the two dates. The order matters: end date minus start date gives a positive number. - Check the result format. If the cell shows a date instead of a number (for example, a date in 1900), the cell is formatted as a date. Select the cell, then use the Number Format dropdown on the Home tab and choose General or Number.
- Copy the formula down if you have more rows. Drag the fill handle (the small square at the bottom-right of the cell) down the column, or copy the cell and paste it into the rows below.
- For whole months or years, use DATEDIF. In the result cell, type
=DATEDIF(A2,B2,"m")for complete months or=DATEDIF(A2,B2,"y")for complete years. Use"d"for days. The function takes the earlier date first. - For working days only, use NETWORKDAYS. Type
=NETWORKDAYS(A2,B2)to count weekdays between the dates, excluding Saturdays and Sundays. Add a range of holiday dates as a third argument if you want those excluded too. - To get a duration in years, months and days, combine DATEDIF results in one cell, for example
=DATEDIF(A2,B2,"y")&" years, "&DATEDIF(A2,B2,"ym")&" months, "&DATEDIF(A2,B2,"md")&" days".
Common Mistakes
- Dates stored as text. If a date was typed with an unusual separator or imported from another system, Excel may treat it as text. Subtraction then returns a
#VALUE!error. Re-enter the date in a recognized format or use Data > Text to Columns to convert it. - Reversing the order.
=A2-B2gives a negative number when A2 is the later date. Swap the cells if you want a positive result. - Result showing as a date. Excel sometimes carries the date format into the result cell. Change the format to General or Number.
- Using DATEDIF with the end date first. DATEDIF returns an error if the start date is later than the end date, so always put the earlier date first.
- Forgetting that times matter. If cells contain both a date and a time, the result includes a fraction of a day. Format the result as a number with decimals, or use
INTto drop the time portion.
Tips
- Use
TODAY()in place of one date to calculate age or elapsed time from the current day, for example=TODAY()-A2. - Press Ctrl+; (Windows) or Cmd+; (Mac) to insert today's date as a static value.
- Name your date cells (select the cell, type a name in the Name Box) so formulas read more clearly, such as
=EndDate-StartDate. - If you need the difference in hours or minutes, multiply the day result by 24 or 1440 and format the cell as a number.
Troubleshooting
The formula returns #VALUE!. One or both cells contain text, not a real date. Check alignment: real dates are right-aligned by default. Re-enter the value or convert the column.
The result is a strange date like 1/1/1900. The cell is formatted as a date. Select it and change the format to General or Number.
The result is negative. The start date is in the later cell. Swap the cell references in the formula.
DATEDIF is not listed in the function suggestions. It is a compatibility function and does not appear in the autocomplete list, but it still works when typed manually. Check spelling and the quotation marks around the unit code.
NETWORKDAYS gives an unexpected count. Confirm both cells are real dates and that any holiday range contains dates, not text. The function counts both the start and end dates if they are weekdays.
If that did not work, select the problem cells, open the Home tab, and set the format to Date or Number as appropriate. If the values still will not calculate, retype them manually in a simple format such as 2025-01-15.
Frequently Asked Questions
Why does Excel return a date instead of a number when I subtract dates?
The result cell inherited a date format. Change it to General or Number on the Home tab and the day count appears.
How do I subtract dates to get months instead of days?
Use =DATEDIF(start,end,"m") for complete months. For a more precise figure that includes fractions of a month, subtract the dates and divide by 30.44, though DATEDIF is usually clearer.
Can I subtract a date from today's date?
Yes. Use =TODAY()-A2 to get the number of days since the date in A2. The result updates each time the workbook recalculates.
Does subtracting dates work the same on Excel for the web and Mac?
Yes. The formulas are identical across Windows, Mac, and the web version. Only the location of some buttons and menus differs.
How do I exclude weekends from a date difference?
Use =NETWORKDAYS(start,end). Add a range of holiday dates as a third argument to exclude them as well.
Why do I get a decimal instead of a whole number?
At least one cell contains a time as well as a date. Wrap the formula in INT, for example =INT(B2-A2), to drop the time portion.