Sub topic 6
Adding and subtracting dates
This chapter assumes you can enter formulas, use relative and absolute cell references, and apply number formats from the Format menu. It also assumes you know that Sheets stores a date as a serial number, a count of days since December 30, 1899. Everything here follows from that fact.
Why date arithmetic works
A date is a number, so the ordinary arithmetic operators work on it. Adding 1 moves a date forward one day. Subtracting one date from another gives the number of days between them. No special function is needed for either.
=A2 + 7
=A2 - 30
=B2 - A2The first formula returns the date one week after A2. The second returns the date 30 days before A2. The third returns the days between A2 and B2.
The result of an addition or subtraction between a date and a plain number is itself a date serial number. The result of subtracting two dates is a plain count of days. Sheets often guesses the display format, and the guess is sometimes wrong, so check the cell format whenever a result looks odd.
Adding days to a date
Suppose A2 holds an invoice date and B2 holds the payment terms in days. The due date is:
=A2 + B2If A2 is 2026-11-28 and B2 is 30, the result is 2026-12-28. Sheets handles month and year boundaries for you, because it is adding to a day count and not editing text.
You can also build the number directly into the formula, but a better habit is to keep it in a labeled cell. Then you can change the terms without editing formulas, and you can reference it with an absolute reference such as $E$1.
=A2 + $E$1Subtracting dates to get a number of days
Subtracting the earlier date from the later one gives a positive count of days.
=B2 - A2If A2 is 2026-11-01 and B2 is 2026-11-28, the result is 27. The start day is not counted, so this is the elapsed time and not the number of calendar days touched. If you want to include both the first and last day, add 1.
=B2 - A2 + 1Sheets also has the DAYS function, which takes the end date first.
=DAYS(B2, A2)DAYS returns the same value as B2 - A2. The argument order is the usual source of mistakes: DAYS(end, start). Reversing it returns a negative number. The operator form is easier to remember, and DAYS has one advantage: it accepts text that looks like a date, such as "2026-11-28", and converts it for you. Do not rely on that conversion in shared sheets, because parsing depends on the locale (see the chapter on converting text and dates).
| Goal | Formula | Result for A2 = 2026-11-01, B2 = 2026-11-28 |
|---|---|---|
| Days elapsed | `=B2 - A2` | 27 |
| Same, using DAYS | `=DAYS(B2, A2)` | 27 |
| Days including both ends | `=B2 - A2 + 1` | 28 |
| Reversed order | `=A2 - B2` | -27 |
Negative results and the sign of a difference
A negative result means the start date is later than the end date. That is often useful. For example, subtracting today from a deadline gives the days remaining, and the number turns negative once the deadline has passed.
=B2 - TODAY()You can turn this into a readable status with IF.
=IF(B2 - TODAY() < 0, "Overdue", "On time")If you need the distance regardless of direction, wrap the subtraction in ABS.
=ABS(B2 - A2)Adding and subtracting date-times
A date-time carries a fraction. The whole part is the date, and the fractional part is the time of day. Noon is 0.5, and 6:00 is 0.25. Subtracting two date-times therefore returns days with a fraction.
=(B2 - A2) * 24This returns elapsed hours. Multiply by 24 60 for minutes, and by 24 60 * 60 for seconds. The next chapter, on time of day and durations, covers display formats for these results in more detail.
To add hours to a date-time, divide by 24 first.
=A2 + 36 / 24This adds 36 hours, which is a day and a half. A common error is =A2 + 36, which adds 36 days.
=A2 + TIME(3, 30, 0)The TIME function gives a clearer way to add a fixed amount of time. This adds three and a half hours.
Where plain arithmetic stops working
Adding days is exact, but months and years are different lengths. Adding 30 to a date does not move it by one month. Adding 365 does not always move it by one year, because leap years have 366 days.
=A2 + 365For A2 = 2027-12-31, this does not give the same day one year later: 2028 is a leap year, so the result is 2028-12-30. For month-based or year-based shifts, use EDATE or the DATE function, which the chapter on month shifts covers. For elapsed months and years, use DATEDIF.
You can rebuild a date with a different year by using DATE with the parts extracted from the original.
=DATE(YEAR(A2) + 1, MONTH(A2), DAY(A2))This has its own edge case. For A2 = 2028-02-29, the formula asks for February 29, 2029. DATE does not return an error. It rolls the extra day over and returns 2029-03-01. Whether that is acceptable depends on your use case.
Counting working days instead of calendar days
Subtracting dates counts every day, including weekends. For working days you need NETWORKDAYS, which a later chapter covers. Be aware now that =B2 - A2 never excludes weekends or holidays.
Common mistakes
The following problems account for most wrong date arithmetic.
- The result shows as a date, not a number. Sheets sometimes applies a date format to a subtraction result, so a 27-day difference displays as a date in December 1899. The value is correct and only the display is wrong. Select the cell and choose Format, then Number, then Automatic or Number.
- A #VALUE! error. One of the cells holds text that looks like a date. Text is left-aligned by default, while real dates are right-aligned. Convert the text with DATEVALUE.
- A result off by one. You decided whether the start day counts. Elapsed time excludes it, and an inclusive count adds 1.
- Hours that are off by a large factor. You forgot that the difference is in days. Multiply by 24 for hours.
- A blank cell treated as a date. A blank cell counts as 0, which is December 30, 1899. Subtracting it gives a result near 46,000. Guard against it with IF.
=IF(OR(A2="", B2=""), "", B2 - A2)Filling a whole column
To compute the difference for every row, write the formula once and let ARRAYFORMULA fill the column.
=ARRAYFORMULA(IF((A2:A="") + (B2:B="") > 0, "", B2:B - A2:A))The addition of two true/false tests acts as an OR. Any row where either date is blank stays empty.
Worked example: a small project schedule
Set up these columns, with a header in row 1 and data from row 2 on.
| Column | Content |
|---|---|
| A | Task start date |
| B | Duration in days |
| C | End date |
| D | Days left from today |
| E | Status |
Enter these formulas in row 2.
C2: =A2 + B2
D2: =C2 - TODAY()
E2: =IF(D2 < 0, "Overdue", IF(D2 <= 7, "Due soon", "On track"))For a start date of 2026-11-20 and a duration of 14 days, C2 is 2026-12-04. With today at 2026-11-28, D2 is 6, and E2 shows "Due soon". Format C2 as a date and D2 as a number.
Because TODAY changes each day, D2 and E2 update when the sheet recalculates. A later chapter covers when that happens.
Exercise
A2 holds the date-time 2026-11-28 08:00 and B2 holds 2026-11-29 14:30. Write a formula that returns the elapsed time in hours, and give the result. Then write one that returns B2 plus 12 hours.
Show answer
Use =(B2 - A2) * 24. The difference is 1.2708333 days, which times 24 gives 30.5 hours. For B2 plus 12 hours use =B2 + 12 / 24, or =B2 + TIME(12, 0, 0). The result is 2026-11-30 02:30.
Exercise
Column A holds invoice dates, and some rows are blank. Cell E1 holds the payment terms in days. Write one formula in B2 that fills the due date for every row of column A and leaves blank rows empty.
Show answer
=ARRAYFORMULA(IF(A2:A="", "", A2:A + $E$1). Format column B as a date. The IF test keeps empty rows from showing 1899-12-30 plus the terms.