Zeller's Congruence
For the Gregorian calendar, the formula is:
Where q is the day of the month, m is the month number, K is the year of the century (the last two digits of the year), J is the zero-based century (the first two digits), and the brackets mean round down to the nearest whole number. The result h maps to a weekday: 0 is Saturday, 1 is Sunday, 2 is Monday, and so on through 6 for Friday.
Why January and February are different
The formula treats the year as running from March through the following February, not January through December. So if your date falls in January or February, you count it as month 13 or 14 of the previous year: subtract 1 from the year and add 12 to the month number before you start. This is just a mathematical convenience, it puts the leap-day adjustment (February 29th) at the very end of the counted year instead of in the middle, which keeps the rest of the formula simpler.
Step by step
- Write down the day, month, and year.
- If the month is January or February, subtract 1 from the year and add 12 to the month (so January becomes month 13, February becomes month 14).
- Split the year into
K(last two digits) andJ(first two digits). - Plug everything into the formula above and reduce mod 7.
- Map the result to a weekday using the 0-through-6 scale (Saturday through Friday).
A worked example
Let's find the weekday for March 15, 1994.
March 15, 1994 was in fact a Tuesday, you can check that against any calendar or the Day of the Week Calculator on this site.
Frequently asked questions
What is Zeller's Congruence?
It's a formula, developed by German mathematician Christian Zeller, that calculates the day of the week for any date in the Gregorian calendar directly from the day, month, and year, without needing a calendar or counting forward day by day.
Why does the formula treat January and February differently?
Zeller's Congruence treats the calendar year as running from March through the following February, so January and February are counted as months 13 and 14 of the previous year. This is a mathematical convenience that makes the leap-day adjustment (February 29th) fall at the very end of the counted year instead of in the middle of it.
Sources
- GeeksforGeeks, Zeller's Congruence, cross-checked against Wikipedia's Zeller's congruence article, nayuki.io, and codedrome.substack.com