Number of Days in a Month

Excel Formulas › Date & Time

All versionsEOMONTHDAY

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.


Quick formula: for any date in A2:
=DAY(EOMONTH(A2, 0))
EOMONTH returns the last day of A2’s month; DAY pulls out the day-of-month number — which is the count of days.

Functions used (tap for the full reference guide):

The example

Days in the month for a few dates (note the leap-year February).

AB
1DateDays
22/10/202628
32/10/202429
44/05/202630

The formula

The number of days in A2’s month:

=DAY(EOMONTH(A2, 0)) // Feb 2026 → 28; Feb 2024 → 29

How it works

Two functions, read inside out:

  1. EOMONTH(A2, 0) returns the last day of A2’s own month — Feb 28, 2026 (or Feb 29 in a leap year).
  2. DAY(…) extracts the day number of that date — 28, 29, 30, or 31.
  3. Because EOMONTH knows about leap years, February correctly returns 28 or 29 with no special handling.
  4. 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

Live demo

Pick a date; see how many days are in its month.

Days in month:

Variations

From a month and year

Build the date first:

=DAY(EOMONTH(DATE(B1, B2, 1), 0))

Is it a leap year?

February has 29 days only in leap years:

=DAY(EOMONTH(DATE(B1, 2, 1), 0)) = 29

Days remaining in the month

From today to month end:

=EOMONTH(TODAY(), 0) - TODAY()

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

📊
Download the free Number of Days in a Month practice workbook
Dates with live days-in-month, the leap-year test and pro-rate variants, plus 4 challenges with answers. No sign-up required.

Frequently asked questions

How do I find the number of days in a month in Excel?
Use =DAY(EOMONTH(A2, 0)). EOMONTH returns the month's last day and DAY reads its number, giving 28, 29, 30, or 31 with leap years handled automatically.
How do I get days in a month from just a month and year?
Build a date first: =DAY(EOMONTH(DATE(year, month, 1), 0)).
How do I check if a year is a leap year?
Test February's length: =DAY(EOMONTH(DATE(year,2,1),0))=29 returns TRUE for leap years.

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

Related formulas: First & last day of month · Add months to a date · Get the week number of a date

Function references: EOMONTH · DAY