Calculateus

Days in a Month Calculator

Find the exact number of days in any given month and year, correctly accounting for leap years.

Result

Days in This Month
28
Leap Year?
No

About the Days in Month

The Days in a Month Calculator reports exactly how many days fall in any given month and year, correctly identifying leap years for February along the way. It removes the need to recall rhymes about month lengths or manually work out whether a particular year is a leap year.

How It Works

You select a month and enter a year. The calculator constructs a date set to day zero of the following month, a technique that causes standard date handling to roll back to the last valid day of the month you actually asked about, then reads off that day number. When the selected month is February, it additionally checks whether the resulting count is 29, which it uses to report whether that year is a leap year.

daysInMonth = the resolved day value for (year, month, day 0), which standard date arithmetic resolves to the final day of the requested month; leap year flag = true only when month is February and daysInMonth equals 29.

Examples

February 2026

2026 is not divisible by 4, so it is not a leap year. The calculator returns 28 days and marks Leap Year as No.

February 2028

2028 is divisible by 4 and is not a century year, so it is a leap year. The calculator returns 29 days and marks Leap Year as Yes.

Advantages

  • Handles the leap year exception automatically, including the less-common century-year rule, without requiring you to remember it.
  • Works for any month, useful for quickly confirming whether a given month has 30 or 31 days.
  • Returns a definitive leap year flag alongside the day count specifically for February.

Common Mistakes

  • Assuming every year divisible by 4 is automatically a leap year, missing the century exception that makes years like 1900 not leap years.
  • Forgetting that leap year status only affects February's day count, since every other month is fixed year to year.
  • Mixing up month indexing when working with raw date values in code, since some systems number months starting from 0 rather than 1.

Edge Cases to Watch For

  • The leap year indicator only appears when February is selected, since it is not relevant to any other month's fixed day count.
  • The leap year determination follows the standard Gregorian rule, divisible by 4 except century years not divisible by 400, so 2000 counts as a leap year while 1900 does not, all handled automatically through the date engine.
  • Entering an unusual or far-off year still works correctly, since the calculation relies on general date arithmetic rather than a limited lookup table.

Common Use Cases

  • People building calendars, schedules, or billing cycles that require an exact month length.
  • Students and trivia players checking leap year rules for a specific year.
  • Developers or spreadsheet users spot-checking date logic against a known-correct reference value.
Written & fact-checked by the Calculateus TeamLast updated August 5, 2026How we verify our formulas

Frequently asked questions

Why does February sometimes have 29 days?

A calendar year (365 days) doesn't exactly match Earth's actual orbital period (about 365.24 days), so an extra day is added to February every 4 years to keep the calendar aligned with the seasons - with the further refinement that century years not divisible by 400 (like 1900) skip the leap day, keeping long-term drift extremely small.

Conclusion

The Days in a Month Calculator gives a definitive day count for any month and year combination, applying the leap year exception correctly including its century-year nuance. It serves as a small but reliable reference point whenever an exact month length matters.