dash–calculator

04 Numbers and Counting

Months and Days of the Year: Complete Guide

Readout 04-0391 · Updated · Standard formula, shown below

The calculator on this page is switched off while it is checked. The formula is below, and the worked example shows how to do the sum by hand.

There are 12 months in a year, and the number of days in each month varies between 28 and 31, totaling 365 days in a common year and 366 in a leap year. This guide explains the calendar structure, the lengths of every month, and the rules that keep our calendar aligned with the seasons.

Formula

The number of days in a month can be found with a simple formula (for a common year, ignoring leap years for February):

Days = 30 + ((m + floor(m/8)) mod 2) – 2 × (1 if m = 2 else 0)

  • m – month number (1 = January, 2 = February, …, 12 = December)
  • floor(m/8) – integer division by 8 (0 for months 1–7, 1 for months 8–12)
  • mod 2 – remainder when divided by 2 (0 or 1)

This formula gives 31 days for months 1,3,5,7,8,10,12; 30 days for months 4,6,9,11; and 28 days for February (29 in a leap year).

Worked Example

Using the default value m = 7 (July):

  1. Compute floor(7/8) = 0
  2. m + floor(m/8) = 7 + 0 = 7
  3. 7 mod 2 = 1
  4. 30 + 1 = 31
  5. Since m = 7 is not 2, subtract 0: Days = 31

The calculator shows 31 days, which matches the length of July.

Why Months Have Different Lengths

The modern Gregorian calendar evolved from the Roman calendar. Originally, the Roman year had 10 months starting in March, then added January and February. July and August were both given 31 days—July after Julius Caesar and August after Augustus—which is why the pattern of alternating 30/31 days is interrupted after July. February, the last month in the early Roman calendar, was left with 28 days (29 in leap years).

Leap Year Rules

To keep the calendar in sync with the solar year (about 365.2422 days), we add an extra day to February every four years. However, the rule is more precise:

  • A year is a leap year if it is divisible by 4.
  • But if the year is divisible by 100, it is not a leap year unless it is also divisible by 400.

So 2000 was a leap year, 1900 was not, and 2100 will not be. This rule gives an average year length of 365.2425 days, very close to the actual solar year.

Memory Tricks for Month Lengths

Many people use the knuckle method: count knuckles and valleys on your fist. Months that land on a knuckle have 31 days; months on a valley have 30 (February is the exception). Start with January on the first knuckle, February in the valley, and so on. When you reach July (the last knuckle on the first hand), continue with August on the first knuckle of the other hand.

Another common rhyme: “Thirty days hath September, April, June, and November; all the rest have thirty-one, except February alone.”

Why February Has 28 Days

February’s short length is a historical accident. In the early Roman calendar, February was the last month and was given fewer days to make the total fit. When the calendar was reformed, February remained the shortest. In leap years, the extra day is added to February, making it 29 days.

Common Mistakes and Misconceptions

  • Assuming all even months have 30 days: July (7) and August (8) both have 31, breaking the pattern.
  • Forgetting leap years: February is 28 days in common years, 29 in leap years; other months never change.
  • Using the wrong formula: Some people think months alternate 30/31 from January, but the alternation breaks after July.

Frequently Asked Questions

How many days are in each month?

January 31, February 28 (29 in leap years), March 31, April 30, May 31, June 30, July 31, August 31, September 30, October 31, November 30, December 31.

Why does February have 28 days?

February was the last month in the early Roman calendar and was given fewer days to make the total fit. The tradition carried into the Julian and Gregorian calendars.

What is the shortest month?

February is the shortest month, with 28 days in a common year and 29 in a leap year.

How many days are in a leap year?

A leap year has 366 days, with an extra day added to February. Leap years occur every 4 years, except for century years not divisible by 400.

Which months have 31 days?

January, March, May, July, August, October, and December have 31 days. This can be remembered with the knuckle method.

Is there a formula to calculate days in a month?

Yes, the formula given above works for common years. For leap years, simply add 1 to February’s result.

Related

Formula used
in m | Month number | - | 7 | 1 | 12
out days | Days in month | days | 30 + (m + floor(m/8)) % 2 - 2 * (m == 2) | 0

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More on this panel

The whole Numbers and Counting panel →