Sub topic 4
Adding and subtracting dates
This chapter assumes you can enter formulas, use cell references such as A2, and apply a number format to a cell. You also need the serial number model from the earlier chapters: a date is a whole number of days, and a format only controls how that number is displayed.
Why arithmetic works
Every date is a count of days, so ordinary + and - operators work on dates. No special function is needed. Adding a number moves the date forward by that many days. Subtracting one date from another gives the number of days between them.
Subtracting dates
Subtract the earlier date from the later one to get a positive count of days.
=DATE(2024,3,1)-DATE(2024,1,1)This returns 60, because January has 31 days and February 2024 has 29. Excel handles leap years for you, so you never need to count days by hand.
The result is a plain number of days, not a date. Excel sometimes applies a date format to the result cell when the inputs were dates. If you see something like 29/02/1900, change the cell's format to General or Number. The cell holds 60, and the date format is only displaying it badly.
Adding days to a date
Put a date in A2 and add a number of days to it:
=A2+30If A2 holds 15 February 2024 (serial 45337), the result is serial 45367. Formatted as a date, that is 16 March 2024. The formula crosses the month boundary and respects February's 29 days without any extra work.
The same works with a reference to a number of days stored in another cell, such as =A2+B2. This is the usual way to build a due date from an invoice date and a payment term.
Subtracting a number moves the date backward: =A2-7 gives the date one week earlier.
Inclusive counts
Subtraction counts the gaps between dates, not the dates themselves. Consider this formula:
=DATE(2024,1,31)-DATE(2024,1,1)It returns 30, but January 1 to January 31 covers 31 calendar days if you count both end dates. Add 1 when your rule is inclusive, such as a booking that charges for both the first and the last night. Decide which rule applies before you write the formula, because the two answers differ by exactly one.
Common errors
| Symptom | Cause | Fix |
|---|---|---|
| Result shows as a date such as 29/02/1900 | The cell has a date format but holds a day count | Set the format to General or Number |
| Result is `####` | A negative day count formatted as a date, or a column too narrow | Swap the operands, or widen the column and use General |
| Result is negative | The earlier date was placed first | Subtract the earlier date from the later one |
| Count is one day short | An inclusive rule was needed | Add 1 |
| `#VALUE!` | One operand is text that only looks like a date | Rebuild it with DATE, or convert the text |
Subtraction answers "how many days" only. It cannot say "how many months", because months have different lengths. Later chapters use EDATE and DATEDIF for that.
Exercise
Cell A2 holds the invoice date 10 January 2024 and B2 holds the payment term of 45 days. Write a formula for the due date. Then say what the value of =DATE(2024,3,31)-DATE(2024,3,1) is and what it is under an inclusive count.
Show answer
The due date is =A2+B2, formatted as a date, which gives 24 February 2024 (10 January + 45 days; January has 31 days, so 21 days remain after January 31, plus 24 more). The subtraction returns 30. An inclusive count of both end dates is 31, which you get with =DATE(2024,3,31)-DATE(2024,3,1)+1.