To find how many days are in a month — 28, 29, 30, or 31 — take the month’s last day with EOMONTH and read its day number. It handles leap years automatically, so you never hard-code 28 vs 29.
The example
Days in the month for a few dates (note the leap-year February).
| A | B | |
|---|---|---|
| 1 | Date | Days |
| 2 | 2/10/2026 | 28 |
| 3 | 2/10/2024 | 29 |
| 4 | 4/05/2026 | 30 |
The formula
The number of days in A2’s month:
How it works
Two functions, read inside out:
EOMONTH(A2, 0)returns the last day of A2’s own month — Feb 28, 2026 (or Feb 29 in a leap year).DAY(…)extracts the day number of that date — 28, 29, 30, or 31.- Because EOMONTH knows about leap years, February correctly returns 28 or 29 with no special handling.
- Only have a month and year, not a full date? Build one:
=DAY(EOMONTH(DATE(yr, mo, 1), 0)).
Pro-rate by month length: a daily rate is monthly / DAY(EOMONTH(A2,0)) — correct for every month without a lookup table of 28/30/31.
Try it: interactive demo
Pick a date; see how many days are in its month.
Variations
From a month and year
Build the date first:
Is it a leap year?
February has 29 days only in leap years:
Days remaining in the month
From today to month end:
Pitfalls & errors
Don’t hard-code 30 or 31. A lookup of fixed lengths breaks on February and leap years. EOMONTH is always right.
Result format. DAY returns a plain number; if the cell shows a date, set it to General/Number.
Text dates fail. EOMONTH needs a real date — convert text dates first.
Practice workbook
Frequently asked questions
How do I find the number of days in a month in Excel?
How do I get days in a month from just a month and year?
How do I check if a year is a leap year?
Stop fighting formulas. Learn them in a day.
This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.
See the Formulas & Functions Class