Doomsday

How do you work out the day of the week of a particular date? For example on which day of the week were you born? It sounds like you would need to work back through every year, or else use a program with a calendar like Outlook.

In fact there's a relatively quick way of working out the day of the week using something called the Doomsday Algorithm invented by John Horton Conway. The "Doomsday" is actually the day of the week of the last day of February which is of course February 28th or February 29th in a leap year. You also need to take into account that there are even months (April, June, August, October, and December) and the remainder are odd. To find the day of the week for a date in history, or the future, the key is to know the Doomsday for the given year.

The key fact is that Doomsday in 1900 was a Wednesday. It is easy to work out any other year in the twentieth or twenty-first centuries by taking the whole number part of (year - 1900)/12 then dividing the remainder by 4, adding the whole number part of the result of this division and the remainder of the second division. All this calculation does is take account of the leap years. Add 4 (for Wednesday) to this result and reduce modulo 7 to get the Doomsday for the year. The rule breaks down at the year 2100 because it is not a leap year. For the twenty-first century you can save effort if you know that Doomsday 2000 is a Tuesday and work forward from there (remember as the year "Tue thousand").

Once you know the Doomsday for the year, you can work out the day of the week for any date by the following rules:

For February, simply work back from the Doomsday by subtraction, so for example if Doomsday is a Wednesday and it is a non-leap year, then February 27th is Tuesday, February 21st is a Wednesday, as is the 14th and the 7th, and so on.

For even months, the nth of the month is a Doomsday. So April 4th is a Doomsday, as is June 6th, August 8th, October 10th and December 12th.

For the odd months you need a mnemonic: On the 9th month Doomsday is on the 5th and on the 5th month Doomsday is on the 9th (remember 9 to 5). On the 7th month Doomsday is on the 11th and on the 11th month Doomsday is on the 7th (remember 7-Eleven). March follows February, the last day of which is always a Doomsday, so March 7th is a Doomsday. For January you can work back from February so that Doomsday is January 31st and so also is the 3rd, except in leap years where it moves forward to January 4th.

Once you know the Doomsday for a given month you can get any other day in that month by simple adding or subtracting.