Mentally calculating the day of the week

In my previous post I mentioned John Conway’s Doomsday rule for calculating the day of the week for any date. This method starts off very simple, but gets more complicated when you actually use it.

This post will present an alternative method that’s easier to use in practice and can be described more succinctly.

Here’s the algorithm.

  1. Take the last two digits of the year and add the number of times 4 divides that number.
  2. Add a constant corresponding to the month.
  3. Add the day of the month.
  4. Subtract 1 in January or February of a leap year.
  5. Take the remainder by 7.

The result is a number that tell you the day of the week.

To be even more succinct, let y be the number formed by the last two digits of the date. Let d be the day of the month. Let L equal 1 if the year is a leap year and the date is in January or February and 0 otherwise. Then the algorithm above can be written as

(y + ⌊y/4⌋ + dL + month constant) % 7.

Here ⌊x⌋ is the floor of x, the greatest integer no greater than x, and x % 7 is the remainder when x is divided by 7.

Update: There are multiple ways to compute the year share, i.e. y + ⌊y/4⌋, that are equivalent mod 7 and easier to carry out mentally than the direct approach.

I’ve deliberately left out a couple details above. What are these month constants, and how does the number at the end give you a day of the week?

Customizing for the 21st century

I learned the method above in the 20th century, and the rule was optimized for the 20th century. You had to subtract 1 for dates in the 21st century.

Also, when I learned the method, it numbered the days of the week with Sunday = 1, Monday = 2, etc. Now I would find it easier to start with Sunday = 0.

Here’s an updated table of month constants that eliminates the need to adjust for dates in the 20th century, and numbers the days of the week from 0.

    | January | 6 | February | 2 | March     | 2 |
    | April   | 5 | May      | 0 | June      | 3 |
    | July    | 5 | August   | 1 | September | 4 |
    | October | 6 | November | 2 | December  | 4 |

If you’d like to number Sunday as 1 rather than 0, add 1 to all the numbers above.

The article I learned this method from came with suggested mnemonics for remembering the month constants. But when you change the constants like I’ve done here, you have to come up with new mnemonics.

Examples

I’m writing this post on Saturday, May 7, 2022. Let’s verify that the method gives the correct day of the week today.

Start with 22, and add 5 because ⌊22/4⌋ = 5. The number for May is 0, so there’s nothing to add for the month. We add 7 because today’s the 7th. This gives us

22 + 5 + 7 = 34

which gives a remainder of 6 mod 7, so this is day 6. Since we started with 0 for Sunday, 6 is Saturday.

Next, let’s do January 15, 2036. We get

36 + 9 + 6 + 15 – 1 = 65

which is 2 mod 7. so January 15 will fall on a Tuesday in 2036. Note that we subtracted 1 because 2036 will be a leap year and our date is in January.

If we want to look at Christmas 2036, we have

36 + 9 + 4 + 25 = 74

which is 4 mod 7, so December 25 will fall on a Thursday in 2036. We didn’t subtract 1 because although 2036 is a leap year, we’re looking at a date after February.

Other centuries

For dates in the 20th century, add 1.

For dates in the 22nd century, subtract 1.

If by some reason you’re reading this article in the 22nd century, make your own table of month constants by subtracting 1 from the numbers in the table above.

More details

When I was at University of Texas, humanities majors had to take a class we called “math for poets.” The class was a hodgepodge of various topics, and the most popular topic when I taught the class was this method. Here’s a handout I gave the class.

That handout is a little slower paced than this blog post, and goes into some explanation for why the method works. (The method was meant to motivate modular arithmetic, one of the topics on the syllabus, so explaining why the method works was secretly the whole point of teaching it.)

The handout is still valid. You can follow it verbatim, or you can replace the table of month constants with the one above and ignore the 21st century correction step.

Related posts

2 thoughts on “Mentally calculating the day of the week

  1. David Lindstrom

    Because 2100 is not a leap year, you subtract 2 instead of 1 to correct for dates in the 22nd century, and dates in January or February of 2100 don’t get the 1 subtracted from them as they would for other 22nd century dates. Or you can treat Jan/Feb 2100 dates using 21st century rules.

Comments are closed.