Sub topic 9
What happens when the target day does not exist
This chapter assumes you can enter formulas, use cell references such as A2, and apply a number format. It also assumes you know that Excel stores a date as a serial number, a count of days.
The problem: months have different lengths
EDATE moves a date by a whole number of months and keeps the day of the month. That works until the target month is too short. Starting on 31 January and moving one month forward asks for 31 February, which does not exist.
Excel does not return an error here. It uses the last day of the target month instead. This behavior is called month-end clamping: the day is clamped (limited) to the last valid day of the month.
=EDATE(DATE(2024,1,31),1)This returns 29 February 2024, serial 45351. 2024 is a leap year, so February has 29 days. In 2023 the same formula would return 28 February.
Clamping in a table
The day you start with decides what you get. These results all use a start date of 31 January 2024 and a months argument of 1, 2, or 3.
| Formula | Result | Why |
|---|---|---|
| `=EDATE(DATE(2024,1,31),1)` | 29 Feb 2024 | February has 29 days |
| `=EDATE(DATE(2024,1,31),2)` | 31 Mar 2024 | March has 31 days |
| `=EDATE(DATE(2024,1,31),3)` | 30 Apr 2024 | April has 30 days |
Each result is calculated from the original date, not from the previous result. That detail matters in the next section.
The drift trap
Suppose you build a monthly schedule by chaining formulas. Cell B2 holds 31 January 2024. Cell B3 contains =EDATE(B2,1), B4 contains =EDATE(B3,1), and so on.
- B2 is 31 Jan 2024.
- B3 is 29 Feb 2024, because 31 February is clamped.
- B4 is 29 Mar 2024. EDATE only sees 29 Feb as its input, so the 31st is lost.
Every later date now falls on the 29th. The clamped day replaced the original day of the month, and nothing restores it.
To avoid this, always count from the first date. Keep the start date in B2 and put the number of months in a helper column, A3 downward (1, 2, 3, ...). Then use this formula in B3 and fill it down:
=EDATE($B$2,A3)The $ signs lock the start date, so each row starts from 31 January. You get 29 Feb, 31 Mar, 30 Apr, 31 May, and so on.
Checking the result
Clamping is easy to miss because the result looks like a normal date. Two checks help:
- Format the result cell as General to see the serial number and confirm the date.
- Compare the day of the result with the day of the start date. If they differ, clamping happened.
=DAY(EDATE(A2,1))<DAY(A2)This returns TRUE when the shifted date landed on an earlier day than the start date, which is the sign of clamping.
Summary
- EDATE returns the same day number in the target month when it exists.
- When it does not exist, EDATE returns the last day of the target month.
- Chained EDATE formulas lose the original day. Anchor each formula to the first date and vary the months argument.
Exercise
B2 holds 30 November 2023. What does =EDATE(B2,3) return, and what does =EDATE(EDATE(B2,3),1) return if B2 held 31 December 2023 instead and you applied it to the result of =EDATE(B2,2)? Answer the first part only if unsure: what is =EDATE(DATE(2023,11,30),3)?
Show answer
=EDATE(DATE(2023,11,30),3) returns 29 February 2024. The 30th does not exist in February 2024, which has 29 days, so EDATE clamps to the last day of the month.
Exercise
A schedule starts on 31 January 2024 in B2. You want payment dates on the 31st or the month end for the next 4 months. Why is =EDATE(B2,1) in B3 followed by =EDATE(B3,1) in B4 a poor choice, and what formula should B4 use instead?
Show answer
The chain turns 31 Jan into 29 Feb in B3, and B4 then gives 29 Mar, so the 31st is lost. Use the start date with a months count instead: =EDATE($B$2,2) in B4, which returns 31 March 2024.