My father has a quirk: When he meets someone new, he asks after the date of birth and

then after a few seconds of reflection, he says the corresponding day of the week.

I do not know exactly how he makes, but he knows many of the weekday data from memory.

This is used to calculate the difference to this particular day.

Though there are algorithms to do that with a computer or a programmable calculator I

was trying to find a way to do it in my mind. However mental arithmetic is not one of my skills.

Let me explain it first with an example: 22.06.1955

Day 22 -> 1

Month 6 -> 4

Year 55 -> 5

--

10 -> 3 -> Wednesday

## Day

This one is easy: it's calculating the remainder after division by 7.

Example: 22 = 3 * 7 + 1Actually you don't have to divide by 7. You just need to know the closest

multiple of 7 which is smaller or equal and then calculate the difference:

22 - 21 = 1

## Month

Here you don't have to calculate anything but keep a table in your mind:

Month 1 2 3 4 5 6 7 8 9 10 11 12As I can't remember such a table very well I rearranged it a little:

Magic number 1 4 3 6 1 4 6 2 5 0 3 5

Month Magic numberFor Januray and March the mapping is identity, for October it is 0 which means it1 2 3 1 4 3

4 5 6 6 1 4

7 8 9 6 2 5

10 11 12 0 3 5

can be ignored. Then you can see that the 2nd and 3rd line both start with 6.

In the 2nd line 1 4 from the first line is repeated but shifted by 1

whereas in the 3rd line 1 is added giving 2 5.

Well, the last line: 10 is 0 and 1 added to 2 gives 3 and 5 is keept.

But I'm sure you'll find a different way to memorize this table.

**How did I calculate this mapping?**

Starting with March which is set to 3 either 31 or 30 is added depending on how many

days the previous month has:

month # days sum % 7(*) Since February is the last month in the list we don't have to take

3 31 3 3

4 30 34 6

5 31 64 1

6 30 95 4

7 31 125 6

8 31 156 2

9 30 187 5

10 31 217 0

11 30 248 3

12 31 278 5

1 31 309 1

2 * 340 4

leap years into account here. This is the reason why we started with March.

## Year

Leap years make things complicated. Here again we have a mapping table:

0 : 00 06 17 23 28 34 45 51 56 62 73 79 84 90 101 107Search the year (- 1900) in the table and find the corresponding number in the leftmost column.

1 : 01 07 12 18 29 35 40 46 57 63 68 74 85 91 96 102

2 : 02 13 19 24 30 41 47 52 58 69 75 80 86 97 103 108

3 : 03 08 14 25 31 36 42 53 59 64 70 81 87 92 98 109

4 : 09 15 20 26 37 43 48 54 65 71 76 82 93 99 104 110

5 : 04 10 21 27 32 38 49 55 60 66 77 83 88 94 105 111

6 : 05 11 16 22 33 39 44 50 61 67 72 78 89 95 100 106

Now this is something I don't want to learn by heart. However you may notice that the pattern

repeates after 28 years so we just need to remember the first 28 years.

Unfortunately calculating modulo 28 isn't something I can do easily in my mind.

This is the easiest way I came up to calculate the number:

- Find the closest multiple of 4 smaller or equal to the year. Keep the difference.

- Divide that multiple of 4 by 2.

- Find the difference to the closest multiple of 7 bigger or equal to that number.

- Add this to the difference from step 2.

Example: 55 = 52 + 3As the calculations are carried out modulo 7 we can also subtract the difference to the

52 : 2 = 26

26 + 2 = 28

3 + 2 = 5

closest multiple of 7 smaller than that number in steps 3 and 4.

Example: 46 = 44 + 2Shortcut for years that are a multiple of 7:

44 : 2 = 22

22 - 1 = 21

2 - 1 = 1

- Find the remainder after dividing by 4

- Multiply that number by 5

Example: 49 = 48 + 1

1 * 5 = 591 = 88 + 3

3 * 5 = 15 = 1 (7)

**Important note**: You may have noticed that the mapping table for the months starts

with March. Thus January and February belong to the year before the actual year.

Therefore for these two months the year has to be reduced by 1 before any calculations.

There are different ways to do that calculation. But it turned out that I can calculate

n modulo 4 quiet fast while I have difficulties to divide a number by 4 if it's bigger than say 50.

On the other I find no trouble to divide a number by 2. Probably it's all a question of training.

However it seems I just don't do enough divisions by 12 to use

Lewis Carroll's method:

Quote:

Add together the number of dozens, the overplus, and the number of 4s in the overplus.

## Day of the week

The following table is used to map the resulting number to the day of the week:

0 Sunday

1 Monday

2 Tuesday

3 Wednesday

4 Thursday

5 Friday

6 Saturday

## Explanation

What we actually do is calculating the difference of the date to 28.02.1900 modulo 7.

This interval is split into three parts from which modulo 7 can be found easier:

22.06.1955Since 28.02.1900 was a Wednesday the mapping table of the months starts with 3.

22 = 1 (7)

0.06.1955

31 + 30 + 31 = 92 = 1 (7)

0.03.1955

55 + 13 = 68 = 5 (7) // 55 : 4 = 13 leap years

0.03.1900

28.02.1900 = 3

--

10 = 3 (7)

What remains unexplained are the two formulas to calculate the mapping of the year:

Let's assume y = 4n + r ; 0 <= r < 4

Then d = 365y + n = y + n (7) // since 365 = 1 (7)

= 4n + r + n = r + 5n = r - 2n (7)

2n = 4n / 2d = r - 4n / 2 (7) // here we use that 2 | 4n

Last not least the case where the year is a multiple of 7:

y = 4n + r = 7k = 0 (7)

r = -4n = 3n (7) // multiply both sides by 5

5r = 15n = n (7)

d = y + n = 0 + 5r (7)

## Restriction

The method described here works only for dates from 01.03.1900 to 28.02.2100.

However it could easily be adjusted.

## Examples

6 July 1979

79 - 76 = 3

76 / 2 = 38

38 - 3 = 35

3 - 3 = 0July -> 6

0 + 6 + 6 = 12 = 5 (7)

or shortened

79 76 3

38 35 -3

0 6 -1 5 -> Friday

December 7th, 1941

41 - 40 = 1

40 / 2 = 20

20 + 1 = 21

1 + 1 = 2Dec -> 5

2 + 5 + 7 = 14 = 0 (7)

or shortened

41 40 1

20 21 1

2 5 0 -> Sunday

20.02.1964

63 - 60 = 3

3 * 5 = 15 = 1 (7)Feb -> 4

1 + 4 + 20 = 25 = 4 (7)

or shortened

63 60 3

15

1 4 -1 4 -> Thursday

## Programming

How about a training program for your favorite HP calculator that displays a random date

and asks you to enter the appropriate day of the week?

*Edited: 7 July 2009, 1:40 p.m. after one or more responses were posted*