jamin on November 2nd, 2006

It’s easier than you might think to calculate the day of the week for a date from September 14th, 1752 (the day the Gregorian calendar was made official in America and England) to the indefinite future.

The days of the week are numbered as follows:

Sunday    1
Monday    2
Tuesday   3
Wednesday 4
Thursday  5
Friday    6
Saturday  0

For each month there is a key value:

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

And finally, the century values:

1700's 2
1800's 0
1900's 5
2000's 4
2100's 2

Now you will be keeping a running total of a series of numbers. First, take the last two digits of the year as your initial number. Divide that number by 4 and discard the remainder. Add the result to your initial number. Then add the century value. Next add the key value for the month in question. Then add the day of the month. Now divide the grand total by 7. The remainder is all that counts.

Example #1:
Suppose we want to know what day of the week December 25th, 2006 is.

Last two digits of year: 6
Divided by 4 (discarding remainder): 1
Century Value: 4
Key Value for December: 1
Day of Month: 25
—-
Total: 37

37 / 7 = 5 with a remainder of 2 so our answer is Monday.

Shortcuts:

  1. All we are concerned with is the remainder after dividing the total by 7. Since we’re adding a sum of numbers, we never have to add a number greater than 6. Any time we are adding a number, we can subtract the largest multiple of 7 that is not greater than that number. And any time our running total reaches a number greater than 6, we can again subtract the largest multiple of 7 that is not greater than our running total. Knowing the multiples of 7 up to 98 will greatly improve your speed.
  2. The next shortcut is obvious, but practical. I typically calculate days of the week for the current year (and often for the next year). I do this often enough that I unintentionally memorize the first three steps. The first three steps are year-specific. If you cache the result of the first three steps, you’ll never have to do the math for that year again. For 2006, the result is 4 (see the first three steps of example #1). So in practice, if I wanted to know the day of the week that Christmas falls on this year I wouldn’t have to do any math for the first bit. I’d just start my running total with 4, then add 1 and 4 to get a final result of 2. Christmas this year falls on a Monday.

Example #2 (using first shortcut):
May 17, 1999

Last two digits of year: 1 (98 is a multiple of 7, so we subtract it from 99)
Divide year by 4 (discarding remainder): 3 (99 / 4 is 25 but 21 is a multiple of 7 so we subtract it from 25)
Century Value: 5

Our running total is now 9 which is 2 more than a multiple of 7,
so we’ll just use that as our running total: 2
Key Value for May: 4
Day of Month: 3 (14 is a multiple of 7, so we’ll subtract that from 17)
—-
Total: 9

7 / 7 = 1 with a remainder of 2 so the answer is Monday.

A note about Leap Years:

If the last two digits of a year are divisible by 4 with no remainder, they are a leap year, and you must subtract 1 from the key values for January and February. Other months are unaffected. Years ending in 00 (the last year in a century*) such as 1800, 1900, and 2000 must be divisible by 400 in order to be a leap year. Thus 1800 and 1900 are not leap years, while 2000 is. Even though such years are the last year in a century technically, for our purposes we are not dealing with centuries, but rather with sets of 100’s such as the 1800’s and the 1900’s. Therefore 1900 should be treated as an ordinary year (not a leap year) in the 1900’s.

Tags: , ,

9 Responses to “Mentally Calculate the Day of the Week for a Date”

  1. Digg the story: http://digg.com/space/Mentally.....for_a_Date

  2. Since the key values for the months and centuries are arbitrary, I prefer taking the value for January as 0 and compensating in the century values for the month values. That is, add 4 (subtract 3) to the month values and add 3 (subtract 4) to the century values. The new month values would be:January 0
    February 3
    March 3
    April 6
    May 1
    June 4
    July 6
    August 2
    September 5
    October 0
    November 3
    December 5And the century values:1700’s 5
    1800’s 3
    1900’s 1
    2000’s 0
    2100’s 5
    This would have an added advantage; the current century would have a value of 0.

  3. Eek! That’s a whole bunch of numbers with no good mnemonic. It looks intimidating to me, and I’m *good* at mental math! How’s it going to look to most people?

    I’d rather use the “key day per month” technique that relies on simple observation and a stunningly clever little mnemonic:

    Look at a calendar. Observe that April 4th (4/4), June 6th (6/6), August 8th (8/8), October 10th (10/10), and December 12th (12/12) are always the same day of the week, no matter what year it is. This year (2006), those dates are all Tuesdays. Next year (2007), they’ll all be Wednesdays. In 2008, they’ll all be Fridays. The mnemonic here is that the key day is the one whose number matches the month number for all the even-numbered months except February. (And February is *always* an exception anyway).

    Now observe that May 9th and September 5th are also the same day of the week (Tuesday, this year). July 11th and November 7th are also that same day of the week. That’s 5/9, 9/5, 7/11, and 11/7, no matter whether you’re using the day/month or month/day writing system. The mnemonic here is “a 9-to-5 job at 7/11″.

    The key day in March is always March 7th, or if you prefer you can think of “March 0th” (the day before March 1st). That also helps you remember that…

    The key day of February is the last day of February: Feb. 29th in leap years, Feb. 28 in non-leap years.

    Finally, the key day of January is Jan. 4th in leap years, Jan. 3rd in other years. Leap years are divisible by 4, so that gives you a mnemonic for January.

    Now you know the day-of-week of one day in each month. In 2006, the following days are all Tuesdays:

    Jan. 3rd (non-leap, so not 4)
    Feb. 28th (last day of Feb.)
    Mar. 7th (”March 0th” plus 7)
    Apr. 4th (4/4)
    May 9th (5/9 or 9/5)
    June 6th (6/6)
    July 11th (7/11 or 11/7)
    August 8th (8/8)
    September 5th (9/5 or 5/9)
    October 10th (10/10)
    November 7th (11/7 or 7/11)
    December 12th (12/12)

    Now you know the day-of-week of one day of the month, the rest is a simple matter of adding or subtracting 7s and then counting. No complicated math necessary, just a couple of simple mnemonics.

  4. Robin: nice observations, but I’m not sure I see how that allows you to easily calculate the day of the week for any arbitrary year. That would work well this year, or any other year you happen to know the key days of the month, but what if you wanted to calculate the day of the week for July 17, 1864? Maybe I’m missing something.

    I do realize that memorization of the key values can be troubling. I will write a separate article in the near future illustrating some techniques such as the “peg” which make the memorization much easier. It does take a bit of practice, of course.

  5. where oh where are the halloween pictures?

  6. I have only one difficulty with the initial approach. Year codes are fine, but how to remember the month codes? That is my only concern.

  7. Thyag, you could either memorize the list of month codes by brute force repetition, or you could use any number of mnemonics to associate the code with the month. I would use the phonetic alphabet and peg.

Trackbacks/Pingbacks

  1. uwog.net
  2. blogsci.com