Day of Week Calculator Β· 7 min read
How to Calculate the Day of the Week by Hand
Christian Zeller published his famous congruence formula in 1882. With a pencil and paper β or just mental arithmetic β you can determine the day of the week for any date in the Gregorian calendar. Here is exactly how.
Zeller's Congruence
Christian Zeller was a German mathematician who in 1882 published a formula for computing the day of the week for any date in the Julian or Gregorian calendars. His formula for the Gregorian calendar is:
h = (q + β13(m+1)/5β + K + βK/4β + βJ/4β β 2J) mod 7
Where:
- h is the day of the week (0 = Saturday, 1 = Sunday, 2 = Monday, 3 = Tuesday, 4 = Wednesday, 5 = Thursday, 6 = Friday)
- q is the day of the month
- m is the month (3 = March, 4 = April, ..., 14 = February β January and February are counted as months 13 and 14 of the previous year)
- K is the year within the century (year mod 100)
- J is the zero-based century (βyear / 100β)
- βxβ means floor β round down to the nearest integer
The January/February rule is critical: those months are treated as months 13 and 14 of the preceding year. So January 15, 1900 is treated as month 13, year 1899.
Worked Example: July 4, 1776
Let's verify what day the Declaration of Independence was signed. The date is July 4, 1776.
Step 1: Identify the components.
- Day: q = 4
- Month: July = m = 7 (no adjustment needed β not January or February)
- Year: 1776, so K = 76, J = 17
Step 2: Calculate each term.
- q = 4
- β13(m+1)/5β = β13 Γ 8 / 5β = β104/5β = β20.8β = 20
- K = 76
- βK/4β = β76/4β = β19β = 19
- βJ/4β = β17/4β = β4.25β = 4
- 2J = 2 Γ 17 = 34
Step 3: Sum the terms.
h = (4 + 20 + 76 + 19 + 4 β 34) mod 7
h = 89 mod 7
h = 89 β (7 Γ 12) = 89 β 84 = 5
h = 5 corresponds to Thursday. July 4, 1776 was indeed a Thursday β the Declaration of Independence was adopted on a Thursday. (It was officially signed by most delegates on August 2, 1776 β also a Thursday, as it happens.)
The January/February Adjustment in Practice
Let's try February 14, 2000 (Valentine's Day, year 2000).
Because February is month 14 in Zeller's system, we shift the year back by one: we use year 1999 instead of 2000.
- q = 14
- m = 14 (February)
- Year = 1999, so K = 99, J = 19
Calculate:
- β13(14+1)/5β = β13 Γ 15 / 5β = β195/5β = β39β = 39
- βK/4β = β99/4β = β24.75β = 24
- βJ/4β = β19/4β = β4.75β = 4
- 2J = 38
h = (14 + 39 + 99 + 24 + 4 β 38) mod 7
h = 142 mod 7
h = 142 β (7 Γ 20) = 142 β 140 = 2
h = 2 corresponds to Monday. February 14, 2000 was indeed a Monday.
Month Code Table
The β13(m+1)/5β term is the heart of the formula β it accounts for the varying lengths of months. Here is what it evaluates to for each month, which you can memorize to speed up mental calculation:
| Month | Zeller m | β13(m+1)/5β |
|---|---|---|
| March | 3 | 10 |
| April | 4 | 13 |
| May | 5 | 15 |
| June | 6 | 18 |
| July | 7 | 20 |
| August | 8 | 23 |
| September | 9 | 26 |
| October | 10 | 28 |
| November | 11 | 31 |
| December | 12 | 33 |
| January (prev yr) | 13 | 36 |
| February (prev yr) | 14 | 39 |
Day Code Output Table
| h value | Day of Week |
|---|---|
| 0 | Saturday |
| 1 | Sunday |
| 2 | Monday |
| 3 | Tuesday |
| 4 | Wednesday |
| 5 | Thursday |
| 6 | Friday |
Handling Negative Results
The formula can produce a negative number before the mod operation, particularly for dates in the 1800s and earlier (because β2J can become a large negative number). In modular arithmetic, β1 mod 7 = 6, not β1. The safe approach: if your sum before mod 7 is negative, add a multiple of 7 large enough to make it positive before dividing.
For example, if your sum before mod is β5: β5 + 7 = 2. h = 2 β Monday.
Julian Calendar Variant
Zeller also published a version for the Julian calendar (used before October 1582 in most of Europe). The Julian variant replaces the β2J term with +5 β J. The January/February treatment remains the same. For dates before October 15, 1582 in Western Europe, use the Julian variant.
If you would rather not do the arithmetic yourself: try the Day of Week Calculator β
References
- Zeller, C. (1882). Kalender-Formeln. Acta Mathematica, 9, 131β136.
- Dershowitz, N., & Reingold, E. M. (2008). Calendrical Calculations (3rd ed.). Cambridge University Press.
- Richards, E. G. (1998). Mapping Time: The Calendar and its History. Oxford University Press.