Time & Calendar
Advanced

Zeller's Congruence

Finds the day of the week for any Gregorian date.

Formula

h=(q+⌊13(m+1)5⌋+K+⌊K4⌋+⌊J4⌋+5J) mod 7h = \left(q + \left\lfloor\tfrac{13(m+1)}{5}\right\rfloor + K + \left\lfloor\tfrac{K}{4}\right\rfloor + \left\lfloor\tfrac{J}{4}\right\rfloor + 5J\right) \bmod 7

Variables

qDay of month
mMonth (Mar=3 … Feb=14)
KYear of century
JZero-based century
h0=Sat,1=Sun,…

Example

For 2000-01-01 the formula returns h = 7 ⇒ Saturday

How it works

Zeller’s Congruence is a modular arithmetic shortcut that turns a calendar date into a weekday number by counting how many days the date is offset from a fixed pattern of 7-day cycles. The month is re-encoded so that March starts the year, which makes leap-day handling much cleaner because February is treated as the last month of the year. The extra floor terms account for the extra day every 4 years, while the century terms correct for the fact that Gregorian leap years are skipped on most century years unless divisible by 400.

When to use it

Use it when you need the weekday for a Gregorian date without consulting a calendar, especially in programming, puzzle solving, historical date checks, or manual verification. It is most useful for dates after the Gregorian reform and for tasks where exact weekday computation matters.

Worked example, step by step

Find the day of the week for 2024-11-05. q = 5 m = 11 (November) K = 24 (year of century from 2024) J = 20 (century from 2024) Compute each part: ⌊13(m+1)/5⌋ = ⌊13(12)/5⌋ = ⌊156/5⌋ = 31 ⌊K/4⌋ = ⌊24/4⌋ = 6 ⌊J/4⌋ = ⌊20/4⌋ = 5 5J = 5×20 = 100 Substitute into the formula: h = (5 + 31 + 24 + 6 + 5 + 100) mod 7 h = 171 mod 7 h = 3 Interpret the result: 0 = Saturday, 1 = Sunday, 2 = Monday, 3 = Tuesday So 2024-11-05 was a Tuesday.

Common mistakes to avoid

  • Using the ordinary month number for January and February instead of treating them as months 13 and 14 of the previous year
  • Forgetting to split the year into K and J correctly, which changes the century adjustment terms
  • Misreading the output mapping for h, since 0 corresponds to Saturday rather than Sunday

Did You Know?

Christian Zeller published this in 1882; January and February count as months 13 and 14 of the previous year.

Share this formula

Reviewed & maintained by the FormulaWon editorial teamLast reviewed September 2026