On what date does Easter fall this year? What day of the week is your dad’s birthday? What day of the week is July 4th this year? Answering questions like this, quickly, without consulting a calendar, seems to be a frequent parlor trick recently. This is a quick post describing the approach that I use to calculate the day of the week of a given date (i.e., year, month, and day).

Note that there are really two common applications here. One is an algorithm for a computer. In that case, I think the best approach is to generalize slightly, using the (modified) Julian day number or something similar to associate consecutive dates with consecutive integers. That algorithm is well-documented. The other application is a method for performing the calculation quickly *in your head*, which is a different problem, and is what I am focusing on here.

There is plenty of literature on this problem as well, the most commonly referenced methods being Conway’s Doomsday algorithm and Zeller’s congruence. The Doomsday algorithm never really appealed to me, seeming to consist of a hierarchical set of special cases progressing from months to years to centuries. And Zeller’s congruence is often presented with the accurate but complicated arithmetic involving the month, which is fine for a computer, but I certainly can’t do it in my head.

The following approach is one that I remember, with some fondness, working out in the backseat of my parents’ station wagon while traveling to visit my grandparents. I had found a book (from the public library, now lost to the mists of antiquity) that contained a perpetual calendar, a two-page table that involved a complex sequence of row/column intersections to determine the day of the week for a given date. I was fascinated by this table, and in an effort to understand how it worked, I tried to turn that complex sequence of steps tracing through the table into a mathematical formula. In hindsight, the result was effectively Zeller’s congruence, but with some slight modifications that I find to be simpler for computing in your head… although this is perhaps only because it is how I learned it.

**The algorithm**: Represent the year as , considering dates in January and February to be in the previous year. Then given also the month and day , the day of the week is given by:

where corresponds to Sunday, to Monday, etc. For example, New Year’s Day 2012 will correspond to , yielding , a Sunday. Note that this formula works for any non-negative century in the (proleptic) Gregorian calendar.