How-to recipes · Dates and times

How to get the first and last day of the month in Excel

Find the first and last day of any month with EOMONTH or DATE, count the days in a month, and get the first Monday or last working day.

Beginner EOMONTH DATE YEAR MONTH DAY WORKDAY WEEKDAY SEQUENCE TODAY

Month boundaries are everywhere in spreadsheets: the period of a monthly report, the due date of an invoice payable at the end of the month, the number of days used to pro-rate rent or a salary, a calendar that starts on the 1st. Because months have 28, 29, 30 or 31 days, you cannot simply add 30. EOMONTH solves the last-day problem in one step, and the first day follows from it.

The example data

One date in A2: 17 February 2026. February 2026 has 28 days.

Last day of the month: EOMONTH

C2fx=EOMONTH(A2,0)
ABC
1Date
22026-02-172026-02-28

Formatted as a date (yyyy-mm-dd). EOMONTH returns a serial number, so apply a date format.

Result: 2026-02-28

EOMONTH stands for end of month. The second argument says how many months to move first: 0 is the same month, 1 the next month, -1 the previous month. So =EOMONTH(A2,1) returns 31 March 2026 and =EOMONTH(A2,-1) returns 31 January 2026. It handles leap years automatically: =EOMONTH(DATE(2028,2,1),0) returns 29 February 2028.

First day of the month

The first day of a month is the day after the last day of the previous month:

C2fx=EOMONTH(A2,-1)+1
ABC
1Date
22026-02-172026-02-01

31 January + 1 day = 1 February. Formatted as a date.

Result: 2026-02-01

A formula that many people find more readable builds the date directly with DATE: =DATE(YEAR(A2),MONTH(A2),1). Both work in every version. For the first day of the next month, use =EOMONTH(A2,0)+1; for the current month as of today, replace A2 with TODAY.

Number of days in the month

DAY of the last date is the number of days: =DAY(EOMONTH(A2,0)) returns 28. This is the basis for pro-rating: rent of 900 for a tenant who moves in on the 17th is =900*(DAY(EOMONTH(A2,0))-DAY(A2)+1)/DAY(EOMONTH(A2,0)), which charges for the days from the 17th to the 28th inclusive.

Microsoft 365: every day of the month

SEQUENCE can generate the whole month from the first day, which is the core of a formula-driven calendar or timesheet:

Formula
=SEQUENCE(DAY(EOMONTH(A2,0)),,EOMONTH(A2,-1)+1)

It spills one row per day, from 1 to 28 February 2026; format the cells as dates. The first three values are shown below with a shorter sequence:

C2fx=SEQUENCE(3,,EOMONTH(A2,-1)+1)
ABC
1Date
22026-02-172026-02-01
32026-02-02
42026-02-03

SEQUENCE(rows, columns, start): 3 rows, starting at 1 February, step 1. Formatted as dates.

First Monday and last working day

  • First Monday of the month: =EOMONTH(A2,-1)+8-WEEKDAY(EOMONTH(A2,-1)+6) returns 02 February 2026. Replace 6 with 5 for Tuesday, 4 for Wednesday, and so on, down to 1 for Saturday and 0 for Sunday.
  • Last working day: =WORKDAY(EOMONTH(A2,0)+1,-1) steps back one working day from the first day of the next month, so a month ending on a weekend returns the Friday before. Add a holiday list as the third argument of WORKDAY.
  • First working day: =WORKDAY(EOMONTH(A2,-1),1).

In older versions

EOMONTH, WORKDAY, DATE and DAY all exist in Excel 2007 and later, so everything except the SEQUENCE listing works in Excel 2016 and 2019. In those versions, build a month list by typing the first day and dragging the fill handle, or with =A2+1 copied down.

Using the boundaries in SUMIFS

Month boundaries make totals by month easy: =SUMIFS(Amount,Date,">="&EOMONTH(A2,-1)+1,Date,"<"&EOMONTH(A2,0)+1) totals the month of A2. Using less than the first day of the next month rather than less than or equal to the last day also includes entries with a time on the last day. See How to sum values by month in Excel.

Pitfalls

  • Number instead of date. EOMONTH returns a serial number such as 46081. Format the cell as a date (Ctrl+Shift+#).
  • Decimal months are truncated. EOMONTH(A2,1.5) is treated as 1.
  • Text dates give #VALUE!; convert them first (How to convert text to a date in Excel).
  • Times. EOMONTH drops any time part and returns midnight of the last day. Compare with < the next month's first day when your data has times.
Tip. To add whole months to a date while keeping the day, see How to add months to a date in Excel. Dates and serial numbers are explained in Dates and times: serial numbers, date math and working days.
⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 15 KB

More how-to recipes