Category Archives:

Calendar

Calculating weekdays in your head

think Since this topic briefly came up during my “mini class reunion” at Christmas, I thought I’d post it here, too, how you can calculate a weekday in your head.

Note: modulo (short: mod) means the remainder of a division of two numbers (e.g. 15 modulo 7 = 1, because 15 = 2·7 + 1), which I will use here for the sake of brevity. The resulting values correspond to the days of the week, hence 7, of course.

We’ll use 20 Nov 2011 as an example. It won’t work without calculation and memorizing, though:

  1. Take the year since 1900 modulo 7. Example: 2011–1900 = 111; 111 mod 7 = 6.
    Hint: You can subtract 70 for starters (or any other multiple of 7) to make it easier; the remainder of the division won’t change because of this, of course.
  2. Due to the leap years, you then add the integer part of one quarter of the years since 19001, in our example 111:4 = 27. And take the remainder of this number too2: 27 mod 7 = 6.
    Hint: Of course it’s 100:4 = 25 for the year 2000, which you can use as an easy-to-remember basis.
    Hint: You can also calculate with -1 instead of 6, since that results in the same value in the end, thanks to modulo 7.
  3. For the month, you memorize this table (which denotes the variations in the weekday for the first days of the months):
    Jan–Mar   0     3     3  
    Apr–Jun   6     1     4  
    Jul–Sep   6     2     5  
    Oct–Dec   0     3     5  

    In the example: 3 for November.
    Hint: It’s probably easiest memorized as row 0-3-3, column 0-6-6-0 and sub-columns 1-2-3   4-5-5(!).
    (I think it would work without such a table, too, but once you got it memorized, I guess it’s easier this way.)

  4. If the date in question is in January or February of a leap year, subtract 1. (Don’t forget!)
  5. Then simply add the day, in the exaple 20. Or straight away the value modulo 7, here 6.
  6. The sum modulo 7 then results in a value from 0 to 6, with 0 for Sunday, 1 for Monday, …, 6 for Saturday.
    Our example thus results in 6+6+3+20 = 35; 35 mod 7 = 0, so 20 Nov 2011 is a Sunday.
    If you used -1 instead of 6: 6-1+3-1 = 7; 7 mod 7 = 0 or -1-1+3-1 = 0.

Quite easy, isn’t it? :mrgreen:


Photo: aidasonne – Fotolia.com

  1. which means this algorithm only applies to 1900–2099 without modifications []
  2. of course you can also just add up everything and then do the modulo 7 calculation once at the end, but that’s probably harder for most… []

Set clocks back: need help!

Today, at the end of daylight savings time in Europe, you must set back your clocks. The problem: How on earth should I get into the shops where I bought the clocks to set them back on the shelves on Sunday when all shops are closed? Break in?? That’s really a stupid rule!

Or how are you doing that? I can’t be the only one having a problem here, can I?