CalcOpenly
English

Leap year checker

Leap year checker: whether a year has 366 days under the Gregorian rule, which test decides it, and the previous and next leap years.

Drafted with AI writing toolsUpdated Checked examples: 5

Try
Result
Common year
Result: Common year
Rule that decides it
Not divisible by 4
Days in the year
365
Days in February
28
Previous leap year
2024
Next leap year
2028

2026 is a common year (not divisible by 4), so February has 28 days. The previous leap year is 2024 and the next is 2028; the Gregorian rule gives 97 leap years every 400 years.

Leap years 2017–2040 shaded, 2026 outlined

201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040
How it's calculated S
  1. Divisible by 4?

    2026 mod 4=22026 \bmod 4 = 2

    No year entered, so this checks the current year, 2026.

    No: a common year.

  2. Divisible by 100?

    2026 mod 100=262026 \bmod 100 = 26

    No: the century rule doesn't apply.

  3. Divisible by 400?

    2026 mod 400=262026 \bmod 400 = 26

    No: not divisible by 400.

About the leap year checker

Under the Gregorian rule a year is a leap year if it is divisible by 4, except century years, which are leap years only if they are also divisible by 400. The checker applies the three tests in order, reports the one that decides, and gives the days in the year and in February and the nearest leap years either side.

Century years are where the rule catches people out. 1900 was a common year because it is divisible by 100 but not by 400, while 2000 was a leap year because it is divisible by 400. The next skipped year is 2100, so the leap year after 2096 is 2104, eight years later.

The rule gives 97 leap years in every 400, an average year of 365.2425 days, about 27 seconds longer than the mean tropical year of 365.24219 days. Years before 1582 are checked with the Gregorian rule extended backwards.

How many days are in a year?

A common year has 365 days and a leap year 366, the extra day being 29 February. A year is a leap year if it divides by 4, except century years, which must also divide by 400. 2026 has 365 days, and 2028 is the next leap year.

The months add up to that total: seven months of 31 days, four of 30 and a 28-day February give 7 × 31 + 4 × 30 + 28 = 365. A leap year's 29 February makes 366.

The leap-year rule, step by step

  1. If the year divides by 400, it is a leap year: 1600, 2000, 2400.
  2. Otherwise, if it divides by 100, it is a common year: 1700, 1800, 1900, 2100.
  3. Otherwise, if it divides by 4, it is a leap year: 2024, 2028.
  4. Any other year is common: 2025, 2026, 2027.

As one test: leap = (divisible by 4 and not by 100) or divisible by 400. The US Naval Observatory's leap-year reference states the same Gregorian rule.

2100 divides by 4 (2100 ÷ 4 = 525) but not by 400 (2100 ÷ 400 = 5.25), so its February has 28 days. 2000 ÷ 400 = 5 exactly, which is why February 2000 had 29.

Leap years around century boundaries

YearClassificationDays in yearFebruary daysPrevious leapNext leap
1600Leap year3662915961604
1700Common year3652816961704
1800Common year3652817961804
1900Common year3652818961904
2000Leap year3662919962004
2024Leap year3662920202028
2026Common year3652820242028
2028Leap year3662920242032
2096Leap year3662920922104
2100Common year3652820962104
2104Leap year3662920962108
2400Leap year3662923962404

Previous and next leap years are strictly before and after the year itself, so a leap year such as 2028 lists 2024 and 2032. Around a skipped century the spacing stretches to eight years, as from 2096 to 2104.

Why there are 97 leap years every 400 years

In 400 years, 100 are divisible by 4. Three of those are century years that fail the 400 test, such as 1700, 1800 and 1900, which leaves 97 leap years.

The cycle therefore has 400 × 365 + 97 = 146,097 days, an average of 365.2425 days a year. That is exactly 20,871 weeks, so the Gregorian calendar repeats with the same weekdays every 400 years.

The Julian calendar used before the Gregorian reform made every fourth year a leap year, 100 in 400, for an average of 365.25 days. Astronomers still use that Julian year of exactly 365.25 days, for example to define the light-year.

Leap years in spreadsheets and code

  • In Excel or Google Sheets, =OR(MOD(A2,400)=0, AND(MOD(A2,4)=0, MOD(A2,100)<>0)) returns TRUE for a leap year in A2.
  • In Python, calendar.isleap(2100) returns False and calendar.isleap(2000) returns True.
  • Excel treats 1900 as a leap year, a quirk kept for compatibility with Lotus 1-2-3, so DATE(1900,2,29) returns a date. A test that asks whether 29 February exists gets 1900 wrong in Excel; the MOD formula does not.

Leap-day mistakes

  • Treating every fourth year as a leap year. Century years break the pattern: 1900 was common and 2100 will be too.
  • Assuming a year from any date is 365 days. From 1 March 2027 to 1 March 2028 is 366 days because 29 February 2028 falls in between. One year after 29 February 2024 is 28 February 2025 in the add/subtract days calculator.
  • Confusing leap days with leap seconds. A leap second adjusts UTC clock time to follow the Earth's rotation; it does not change the number of days in a year.
  • Expecting 53 weeks in a leap year. ISO week years have 52 or 53 weeks either way: 2020 had 53 but 2024 has 52. The week number calculator gives the count for any year.
  • Checking a Julian-calendar year with the Gregorian rule. 1500 was a leap year in the Julian calendar then in use, but the extended Gregorian rule makes it common.

Entering a year

  • Whole years from −999,999 to 999,999. Leave the year blank to check the current year on your device.
  • Year 0 and negative years use astronomical numbering, where 0 is 1 BC and −1 is 2 BC. Under the extended Gregorian rule, year 0 is a leap year.
  • Years before 1582 are checked with the Gregorian rule extended backwards, as in the 1500 example above.

To count the days between two dates, use the date difference calculator. The day of the week calculator shows which weekday 29 February falls on in a given year.

Worked examples

2024

Year
2024
Result
Leap year
Rule that decides it
Divisible by 4 but not by 100
Days in the year
366
Previous leap year
2020
Next leap year
2028

Checked against: Independent calculation

1900, a century year

Year
1900
Result
Common year
Rule that decides it
Divisible by 100 but not by 400
Days in February
28
Next leap year
1904
Previous leap year
1896

Checked against: Independent calculation

2000, divisible by 400

Year
2000
Result
Leap year
Rule that decides it
Divisible by 400
Days in February
29

Checked against: Independent calculation

Leap years skip 2100

Year
2096
Result
Leap year
Next leap year
2104
Previous leap year
2092

Checked against: Independent calculation

Questions

Why is 2100 not a leap year?

Because century years must be divisible by 400 to be leap years, and 2100 ÷ 400 = 5.25. February 2100 will have 28 days, and there will be no leap year between 2096 and 2104. The same rule made 1700, 1800 and 1900 common years, while 1600 and 2000 were leap years. The next century leap year is 2400.

Why do we have leap years?

The year of the seasons, the tropical year, is about 365.2422 days, so a 365-day calendar would slip by almost a day every 4 years and about 24 days a century. The Julian calendar's leap day every fourth year overcorrected by about 11 minutes a year; by 1582 the March equinox had drifted 10 days, which the Gregorian reform removed and the century rule prevents from recurring.

When was the Gregorian calendar adopted?

Pope Gregory XIII decreed it in the bull Inter gravissimas of 24 February 1582. Italy, Spain, Portugal and Poland switched that October, when 4 October was followed by 15 October. Britain and its colonies changed in September 1752, dropping 11 days; Russia in February 1918, dropping 13; and Greece in 1923, also dropping 13.

When is the next leap year?

2028. The leap years after it are 2032 and 2036, and 29 February falls on a Tuesday in 2028, a Sunday in 2032 and a Friday in 2036. Every year divisible by 4 up to 2096 is a leap year, because the first century year in that run that fails the 400 test is 2100.

About this calculator

leap  ⟺  (y mod 4=0∧y mod 100≠0)∨y mod 400=0\text{leap} \iff (y \bmod 4 = 0 \land y \bmod 100 \ne 0) \lor y \bmod 400 = 0

Sources

  1. Pope Gregory XIII, Inter gravissimas (1582) — the Gregorian leap-year rule
  2. US Naval Observatory — Leap years

Checked against references

This calculator includes 5 worked examples with independently sourced answers. They run in the test suite, and you can run them here too.

Put this calculator on your site

Paste this where you want the calculator to appear. It is free to use, it stays in step with corrections made here, and the credit line below it links back so your readers can find the full version.

Height
Preview the embed

Keep the credit line. It is the only condition, and it is what keeps these calculators free.