ArticleslgStudy

computer science

Zeller's congruence

Zeller's congruence is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Zeller's congruence rather than just read about it. In short: Zeller's congruence is an algorithm devised by Christian Zeller in the 19th century to calculate the day of the week for any Julian or Gregorian calendar date. It can be considered to be based on the conversion between Julian day and the calendar date.

Key takeaways

  • Zeller's congruence belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Zeller's congruence to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Zeller's congruence from memory before moving on to harder problems.

Reference excerpt

Zeller's congruence is an algorithm devised by Christian Zeller in the 19th century to calculate the day of the week for any Julian or Gregorian calendar date. It can be considered to be based on the conversion between Julian day and the calendar date.

Formula For the Gregorian calendar, Zeller's congruence is

h = ( q + ⌊ 13 ( m + 1 ) 5 ⌋ + K + ⌊ K 4 ⌋ + ⌊ J 4 ⌋ − 2 J ) mod 7 , {\displaystyle h=\left(q+\left\lfloor {\frac {13(m+1)}{5}}\right\rfloor +K+\left\lfloor {\frac {K}{4}}\right\rfloor +\left\lfloor {\frac {J}{4}}\right\rfloor -2J\right){\bmod {7}},}

for the Julian calendar it is

h = ( q + ⌊ 13 ( m + 1 ) 5 ⌋ + K + ⌊ K 4 ⌋ + 5 − J ) mod 7 , {\displaystyle h=\left(q+\left\lfloor {\frac {13(m+1)}{5}}\right\rfloor +K+\left\lfloor {\frac {K}{4}}\right\rfloor +5-J\right){\bmod {7}},}

where

h is the day of the week (0 = Saturday, 1 = Sunday, 2 = Monday, ..., 6 = Friday) q is the day of the month m is the month (3 = March, 4 = April, 5 = May, ..., 14 = February) K the year of the century ( ( a d j Y e a r ) mod 1 00 ) {\displaystyle ((adjYear){\bmod {1}}00)} . (The adjYear (adjusted year) is explained in the Note below.) J is the zero-based century (actually ⌊ ( a d j Y e a r ) / 100 ⌋ {\displaystyle \lfloor (adjYear)/100\rfloor } ) For example, the zero-based centuries for 1995 and 2000 are 19 and 20 respectively (not to be confused with the common ordinal century enumeration which indicates 20th for both cases).

⌊ . . . ⌋ {\displaystyle \lfloor ...\rfloor } is the floor function or integer part mod is the modulo operation or remainder after division Note: In this algorithm January and February are counted as months 13 and 14 of the previous year. E.g. if it is 2 February 2026 (02/02/2026 in DD/MM/YYYY), the algorithm counts the date as the second day of the fourteenth month of 2025 (02/14/2025 in DD/MM/YYYY format) So the adjusted year above is:

a d j Y e a r {\displaystyle adjYear} = the actual year, for months from March to December.

a d j Y e a r {\displaystyle adjYear} = the previous year, for January and February. For an ISO week date Day-of-Week d (1 = Monday to 7 = Sunday), use

d = ( ( h + 5 ) mod 7 ) + 1 {\displaystyle d=((h+5){\bmod {7}})+1}

Analysis These formulas are based on the observation that the day of the week progresses in a predictable manner based upon each subpart of that date. Each term within the formula is used to calculate the offset needed to obtain the correct day of the week. For the Gregorian calendar, the various parts of this formula can therefore be understood as follows:

q {\displaystyle q} represents the progression of the day of the week based on the day of the month, since each successive day results in an additional offset of 1 in the day of the week.

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Zeller's congruence

Start with the simplest possible case. Write down what Zeller's congruence claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Zeller's congruence before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Zeller's congruence ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Zeller's congruence

In research
Zeller's congruence appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Zeller's congruence in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Zeller's congruence is common in secondary-school and first-year university syllabi. It links to neighbouring topics Calendar algorithms, Gregorian calendar, Julian calendar, so understanding it makes those chapters shorter.
In everyday life
Look for Zeller's congruence outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Zeller's congruence” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Zeller's congruence in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Zeller's congruence means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Zeller's congruence out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Zeller's congruence in simple terms?

Zeller's congruence is an algorithm devised by Christian Zeller in the 19th century to calculate the day of the week for any Julian or Gregorian calendar date. It can be considered to be based on the conversion between Julian day and the calendar date.

Why does Zeller's congruence matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Zeller's congruence?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Zeller's congruence.

Tags

  • Calendar algorithms
  • Gregorian calendar
  • Julian calendar
  • Modular arithmetic

Keep exploring