## Thursday 7 July 2011

### Day of the Week Trick

Today I learnt something really cool: how to work out what day of the week any given date is. It's really easy actually.

First, work out the year code as follows (here, [ ] means integer part, ie round down to a whole number)

Year code (2000 + x) = [x/4] + x (mod 7)
Year code (1900 + x) = [x/4] + x + 1 (mod 7)

Mod 7 means find the remainder once divided by 7.

Example: 1989: [89/4] = 22
22+89 = 111
111 + 1 = 112
112 = 0 mod 7 (because it's divisible by 7).

FYI, 2011's year code is 6, and 2012's is 1.

You also need to know the month code. You have to just memorise these.

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

January and February are different if the year is a leap year.
I memorised these pretty quickly by making up mnemonics. e.g. for May being 0 I remember mayo (which I hate by the way). For August being 1 I remember that A is the 1st letter in the alphabet.

Once you've done that, add together the day, the month code, and the year code, and then reduce it modulo 7 (i.e. find the remainder once divided by 7).

Then that tells you the day: Monday = 1, Tuesday = 2 etc.

Example: 4th March 2012
4 + 2 + 1 = 7 = 0 mod 7 so it’s a Sunday.

Example: 22nd February 1989
22 + 2 + 112 = 136 = 3 mod 7 so it was a Wednesday.

I can do it almost instantly for dates in 2011 and 2012. Other dates are harder because I have to work out the year code. But people are more likely to ask what day of the week an upcoming event is, so knowing these two years is very useful for impressing people.

By the way, I've edited my settings so that you don't have to sign up to anything if you want to leave a comment (well hopefully that's what I've done) so that commenting is now easier and faster. So please drop me a comment if you have a minute, I'd really appreciate it :)

Emma x x x