Sub topic 10
EOMONTH: last day of a month, and first-of-month tricks
This chapter assumes you can enter formulas, use cell references such as A2, and apply a date format to a cell. It also assumes you know that a date is a serial number, which the earlier chapters covered. EOMONTH ("end of month") returns the serial number of the last day of a month. That month can be the one containing a date, or one a set number of months before or after it.
The syntax
=EOMONTH(start_date, months)start_dateis a date, usually a cell reference or aDATEresult.monthsis how many months to move. Use 0 for the same month, a positive number for later months, and a negative number for earlier months. A fractional value is truncated, so 1.9 is treated as 1.
The result is a serial number. If the cell is formatted as General, you see a number such as 45322. Apply a date format to read it as a date.
=EOMONTH(DATE(2024,1,15),0)This returns 31 January 2024, serial 45322, because a months value of 0 stays in the same month.
How EOMONTH differs from EDATE
EDATE keeps the day of the month where it can, and clamps it to the month's last day only when the target day does not exist. EOMONTH ignores the day and always returns the last day. The difference shows when the start date is already a month end.
| Formula | Result |
|---|---|
| `=EDATE(DATE(2024,2,29),1)` | 29 March 2024 |
| `=EOMONTH(DATE(2024,2,29),1)` | 31 March 2024 |
Use EOMONTH for month-end schedules such as statement dates, because EDATE drifts away from month end after a short month.
The first-of-month trick
Excel has no function that returns the first day of a month. You build it from EOMONTH. Go to the last day of the previous month, then add one day.
=EOMONTH(A2,-1)+1Suppose A2 holds 15 March 2023, serial 45000. Then EOMONTH(A2,-1) is 28 February 2023 (serial 44985), and adding 1 gives 1 March 2023 (serial 44986). This works because dates are plain numbers, so +1 moves forward exactly one day. It also handles leap years and varying month lengths with no extra logic.
Other common patterns
With A2 still holding 15 March 2023, these formulas follow from the same idea.
=EOMONTH(A2,0)
=EOMONTH(A2,0)+1
=EOMONTH(A2,1)
=DAY(EOMONTH(A2,0))
=EOMONTH(A2,0)-A2=EOMONTH(A2,0)gives the month end, 31 March 2023.=EOMONTH(A2,0)+1gives the first day of the next month, 1 April 2023.=EOMONTH(A2,1)gives the end of the next month, 30 April 2023.=DAY(EOMONTH(A2,0))gives the number of days in the month, 31.=EOMONTH(A2,0)-A2gives the days left in the month, 16.
The first-day formula pairs well with the month-end formula to define a whole month. Use EOMONTH(A2,-1)+1 as the start and EOMONTH(A2,0) as the end.
Common errors
- The result shows as 45322 instead of a date. The cell has a General or Number format. Apply a date format.
#VALUE!appears. Thestart_dateis probably text that Excel cannot read as a date. Convert it withDATEorDATEVALUE.#NUM!appears. The result would fall outside Excel's valid date range.
Exercise
A2 holds 10 August 2024. Write one formula that returns the number of days in the month before A2's month. What does it return?
Show answer
Use =DAY(EOMONTH(A2,-1)). EOMONTH(A2,-1) is 31 July 2024, and DAY of that date is 31.