The question this page settles

Month length looks like trivia until a spreadsheet, a billing cycle or a payroll run depends on it. Software that spreads a monthly amount over daily rates, a rental agreement that charges by the day and a schedule that needs the last working day all start from the same fact: how many days does this month have in this year. The page answers it for any Gregorian month from year 1 to year 9999. You provide the year as a whole number and the month as a number from 1 to 12, and it returns the day count. January is 1 and December is 12, so there is no month name to misspell.

Thirty days hath September

Seven months have 31 days: January, March, May, July, August, October and December. Four have 30: April, June, September and November. February has 28 days in an ordinary year and 29 in a leap year. Added up, an ordinary year has 7 × 31 + 4 × 30 + 28 = 365 days, and a leap year has 366. The familiar rhyme and the knuckle trick both encode the same list. Because only February varies, the page needs the year for one month out of twelve, but it asks for both inputs every time so that the result is always tied to a specific calendar year.

The leap-year test for February

February gets its extra day when the year is divisible by 4, except for century years, which must also be divisible by 400. In code this reads (year % 4 == 0) and ((year % 100 != 0) or (year % 400 == 0)). The default input of year 2024 and month 2 gives 29, because 2024 divides evenly by 4 and is not a century year. Year 2023 gives 28. The century exceptions trip people up: 1900 and 2100 give 28, while 2000 gives 29 because 2000 is divisible by 400. A shortcut such as "every fourth year" is therefore right for most of the calendar and wrong exactly on those century boundaries. Years such as 2096 and 2104 are ordinary leap years, but 2100 sits between them and has a 28-day February, so a schedule that runs past the end of this century needs the full rule.

Using month length for daily rates

A common use is converting a monthly figure into a per-day figure. A 1,200 subscription spread across a 30-day April costs 40.00 a day, while the same fee spread across a 31-day May costs about 38.71 a day. For a February in a leap year the daily rate would be 1,200 / 29, about 41.38, and in an ordinary year 1,200 / 28, about 42.86. Prorated rent, utility estimates and project burn rates all shift by these amounts. Whether your contract uses the actual month length or a flat 30-day month is a matter of the agreement, so check the wording before you rely on the day count.

Last day of the month and date arithmetic

The number returned is also the last valid day of the month, which is what you need when validating a date or building an end-of-month schedule. A date such as 2023-02-29 does not exist, and 2024-04-31 does not exist either. When software adds one month to January 31, it has to choose a result for February, and many libraries clamp to the final valid day, giving February 28 or 29. Looking up the month length first tells you whether a requested day is valid and where such a clamp would land. Developers often use the same check to reject impossible dates in forms before they reach a database.

Why leap days exist

The Gregorian calendar was introduced by Pope Gregory XIII in 1582 to keep the calendar year aligned with the seasons. A solar year is about 365.2422 days, so a plain 365-day year drifts by nearly a quarter day each year. Adding a leap day every fourth year gives an average of 365.25, which still runs a little long, and skipping three leap days every 400 years brings the average to 365.2425. Over a 400-year cycle there are 97 leap years and 146,097 days. The rule is simple enough to evaluate in your head, and it is the one this page applies for every year in its range.

Years before the calendar existed

Many countries kept using the Julian calendar long after 1582, and Britain and its colonies changed only in 1752. Dates before the local changeover were recorded in a different system, and the missing days at the switch are not counted here. This page uses the proleptic Gregorian calendar, which extends the modern rule backward and forward as if it had always applied. That is the convention used by ISO 8601 and by the date formats described in RFC 3339, and it gives a consistent answer for any year from 1 to 9999. For a historical document with a local calendar date before the changeover, the real month may have been counted differently.

Quarters, half-years and the leap-day shift

Month lengths add up to the longer periods that reports use. In an ordinary year the first quarter has 31 + 28 + 31 = 90 days, the second has 30 + 31 + 30 = 91, and the third and fourth have 92 each. In a leap year the first quarter grows to 91 days. The first half of an ordinary year has 181 days and the second half has 184, so the halves are not equal even though they hold six months each. This matters for revenue per day, utilization rates and anything normalized by elapsed days. Looking up the single month with this page and summing the results is more reliable than assuming 30 days per month, which would give 360 for a year that has 365 or 366.

Input limits

The year must be a whole number between 1 and 9999, and the month a whole number between 1 and 12. Entries outside those ranges are rejected, and so are decimals and month names. The result is a plain count of days and says nothing about weekdays, business days or holidays. If you need to know which weekday a month begins on, or how many working days it holds, use a calculator built for that question. February in particular should be saved together with its year, since the same month number gives different answers across years.