Excel guide · 4 min read
How to get the number of days in a month in Excel
=DAY(EOMONTH(A2,0)). EOMONTH finds the last day of the month that A2 is in, and DAY returns its day number, which is the number of days in that month: 28, 29, 30 or 31. Leap years are handled automatically. For days left in the month, use =EOMONTH(A2,0)-A2.Sample data
Every result on this page was calculated from this sheet by the same spreadsheet engine the Cellwise app uses.
| A | B | C | D | E | F | G | H | |
|---|---|---|---|---|---|---|---|---|
| 1 | Tenant | Move-in date | Monthly rent | Year | 2028 | |||
| 2 | Unit 1A - Okafor | Nov 12, 2026 | 1450 | Month | 2 | |||
| 3 | Unit 1B - Lindqvist | Feb 20, 2026 | 1200 | |||||
| 4 | Unit 2A - Moreno | Feb 20, 2028 | 1200 | |||||
| 5 | Unit 2B - Tanaka | Dec 1, 2026 | 1600 | |||||
| 6 | Unit 3A - Brennan | Sep 30, 2026 | 1375 |
Download this sheet as an Excel practice file (.xlsx)
DAY(EOMONTH(A2,0)): days in the month of a date
The sheet lists tenants with their move-in date and monthly rent. To find how many days the move-in month has, take the month's last day with EOMONTH, then take its day number with DAY. The last day of a 30-day month is the 30th, so the answer is 30.
Change 0 to 1 for the number of days in next month: =DAY(EOMONTH(B2,1)) returns 31 for December.
Result: 30
30: November 2026 has 30 days.
February and leap years
February is the month that breaks lookup tables and hard-coded day counts. EOMONTH follows the calendar rules, so it returns 28 for February 2026 and 29 for February 2028. Century years follow the full rule too: =DAY(EOMONTH(DATE(2100,2,1),0)) returns 28, and 2000 returns 29.
The same idea tells you whether a year is a leap year: =IF(DAY(EOMONTH(DATE(H1,2,1),0))=29,"Leap year","Not a leap year") returns Leap year for 2028.
One quirk: for compatibility with Lotus 1-2-3, Excel treats 1900 as a leap year and accepts February 29, 1900, a date that never existed. It only affects dates before March 1, 1900, so it rarely matters in real files.
Result: 29
29: February 2028 is a leap month. B3, in February 2026, returns 28.
From a year and month number, not a date
If you only have a year in H1 and a month number in H2, build a date with DATE. Day 0 of the following month is the last day of this month, so DAY(DATE(year,month+1,0)) is the day count. For December, month+1 is 13, and DATE rolls that into January of the next year, so you do not need a special case.
If the month is a name such as "Feb" in a cell, convert it first; EOMONTH("Feb 2028",0) returns #VALUE! because the text is not a date. A real date in the cell, formatted to show only mmm yyyy, avoids the problem.
Result: 29
29 for February 2028.
Days left in the month, and days so far
Subtract the date from the month end. =EOMONTH(B2,0)-B2 returns 18 for November 12: the days after the 12th. Add 1 if the date itself should count, as it does for a tenant who moves in that day. The days already passed are simply DAY(B2), or DAY(B2)-1 if today should not count yet.
For a live countdown, use TODAY: =EOMONTH(TODAY(),0)-TODAY(). If the result shows as a date like Jan 18, 1900, the cell picked up a date format; set it to General.
Result: 19
19 days, from November 12 to November 30 with both days counted.
Prorating a monthly amount
A monthly charge for part of a month is usually the monthly amount divided by the days in that month, times the days used. For Okafor, who moves in on November 12: 1,450 divided by 30, times 19 days. The same formula gives a full 1,600 for Tanaka, who moves in on the 1st, and 45.83 for Brennan, who moves in on September 30 and pays for one day.
This is not the only method. Some contracts use a 365-day year instead, =ROUND(C2*12/365*(EOMONTH(B2,0)-B2+1),2), which gives 905.75 for Okafor; others count 30 days in every month. Use the method your lease or contract specifies, and put that choice in a labelled cell rather than burying it in the formula.
Result: 918.33
918.33: 19 of November's 30 days of a 1,450 rent.
Working days in a month
For staffing, billing hours or a daily sales target, you often need weekdays, not calendar days. NETWORKDAYS counts Monday to Friday between two dates, including both ends. Give it the first and last day of the month.
Add a holiday list as the third argument to skip public holidays: with November 26, 2026 in it, =NETWORKDAYS(EOMONTH(B2,-1)+1,EOMONTH(B2,0),DATE(2026,11,26)) returns 20. In practice, keep the holidays in a range and point at it.
Result: 21
21 weekdays in November 2026.
Days in a quarter or a year
A quarter's days are its last day minus its first day plus one. The first day of the quarter is DATE(YEAR(B2),INT((MONTH(B2)-1)/3)*3+1,1), and EOMONTH of that date two months on is the quarter's last day. The first quarter has 90 days in 2026 and 91 in 2028, because of February.
For a year, subtract January 1 from the next January 1: =DATE(YEAR(B2)+1,1,1)-DATE(YEAR(B2),1,1) returns 365 for 2026 and 366 for 2028.
Result: 92
92: October, November and December 2026 (31 + 30 + 31).
Common mistakes
Hard-coding 30 days
Dividing by 30 overcharges in February and undercharges in 31-day months. Use DAY(EOMONTH(date,0)) unless your contract really says 30.
Off by one on days left
EOMONTH(A2,0)-A2 does not count A2 itself. Add 1 when the start date is a day that counts, such as a move-in day.
The result shows as a date
A day count like 18 can display as Jan 18, 1900 if the cell has a date format. Set the cell to General or Number.
Text instead of a date
EOMONTH needs a real date. A month name or an imported text date returns #VALUE!; convert the column or build the date with DATE(year,month,1).
FAQ
What is the formula for the number of days in a month in Excel?
=DAY(EOMONTH(A2,0)) returns the number of days in the month of the date in A2. Without EOMONTH, =DAY(DATE(YEAR(A2),MONTH(A2)+1,0)) does the same.
How do I count the days in the current month?
Use =DAY(EOMONTH(TODAY(),0)). It updates automatically when the month changes.
How do I calculate the days remaining in the month?
Use =EOMONTH(A2,0)-A2, or =EOMONTH(TODAY(),0)-TODAY() for today. Add 1 to count the start day too.
How do I get the number of working days in a month?
Use =NETWORKDAYS(EOMONTH(A2,-1)+1,EOMONTH(A2,0),holidays), where holidays is a range of public holiday dates. Leave out the third argument to count every Monday to Friday.
Functions used
DAYDay of the monthEOMONTHLast day of a monthDATEBuilds a dateYEARYear of a dateMONTHMonth numberINTRounds down to integerIFPicks a result from a testROUNDRounds to digitsNETWORKDAYSWeekdays between datesTODAYToday’s date
Related guides
- How to find the last day of the month in Excel
- How to calculate days between two dates in Excel
- How to count working days between two dates in Excel
- Countdown in Excel: how many days until a date
- How to get the first day of the month in Excel
- How to add months to a date in Excel
- How to calculate weeks between two dates in Excel
Updated