Zeller Congruence — Day of Week
Compute the day of week for any date using Zeller Congruence — 1882 algorithm requiring only modular arithmetic. Shows each step (q, m, K, J, h) for didactic purposes. Supports Julian and Gregorian calendars.
About Zeller’s congruence
Published by Christian Zeller in 1882, the congruence works out the day of the week with modular arithmetic alone: h = (q + ⌊13(m+1)/5⌋ + K + ⌊K/4⌋ + ⌊J/4⌋ + 5J) mod 7 (Gregorian). January and February count as months 13 and 14 of the previous year. By convention: 0 = Saturday, 1 = Sunday, ..., 6 = Friday.
Zeller's congruence, step by step
Christian Zeller published a closed formula in the 1880s that returns the weekday of a date in a single expression, with no table and no loop. It still shows up in code because it is short and uses nothing but integer division — no floating point, no date library. The page breaks out each term, which helps both for checking an implementation and for seeing where every number comes from.
The trick that makes the formula work is treating January and February as months 13 and 14 of the previous year. That moves the variable-length month to the end of the year, so the leap day stops shifting every month after it. The same device appears in nearly every serious calendar algorithm, including the ones that convert to Julian day.
Note that the result starts on Saturday: the formula returns zero for Saturday, one for Sunday, and so on. It is a convention that catches out anyone expecting Sunday as zero, and the most common cause of a seven-day error in hastily copied implementations. The page also handles the Julian calendar, which changes two terms of the expression, and rejects dates that do not exist, such as 31 February.
Frequently asked questions
Why does the formula start on Saturday?
What changes in the Julian calendar?
Zeller or Doomsday, for programming?
Related Tools
Akan Day Name
Return the Akan day name (West African system, Ghana) based on the day of week. Babies are given the day-name of their birth (e.g. Kofi = Friday).
Day of the Week Finder
Find out what day of the week any date fell on (or will fall on), from year 1 to 9999. Great for your birth day, historical dates and future events.
Business Days Calculator
Calculate the number of business days (Monday to Friday) between two dates. Shows total days, business days and weekends.
Week & Day of Year
For any date, computes the ISO 8601 week number, day of year (1-366) and the quarter.
Doomsday Rule (Conway)
Mentally calculate the day of week for any date using Conway's Doomsday Rule, with step-by-step anchor and doomsday of year.
Bengali Calendar Converter
Convert a Gregorian date to the Bengali (Bangabda) calendar, used in Bangladesh and India. Useful for cultural dates, festivals and study.