Calculating the day of the week
This article details a mathematical algorithm to calculate on which day of the week any particular date fell or will fall. There are a number of other algorithms to do this, but they are all variants of each other, simply using different rules to achieve the same result.A typical application is to calculate the day of the week on which someone was born.
| Table of contents |
|
2 Useful Concepts 3 The Algorithm to Calculate the Day of the Week 4 References |
The basis of all the algorithms to calculate the day of the week is:
'Corresponding months' are those months within the calendar year that start on the same day. For example, September and December correspond, because September 1 falls on the same day as December 1. Months can only correspond if the number of days between their first days is divisible by 7, or in other words, if their first days are a whole number of weeks apart. For example, February corresponds to March because February has 28 days, a number divisible by 7, 28 days being exactly four weeks.
In a leap year, January and February correspond to different months than in a common year, since Feb 29 means each subsequent month starts a day later.
Here's how the months correspond:
There are 7 possible days that a year can start on, and leap years will alter the day of the week after February 29. This means that there are 14 configurations that a year can have. All the configurations are referenced in the article on Dominical letter. For example, 2003 was a common year starting on Wednesday, meaning that 2003 corresponds to the 1997 calendar year. 2004, on the other hand, is a leap year starting on Thursday, meaning that the year starts off corresponding to 1998 and ends corresponding to 1999.
The algorithm is valid for the Gregorian Calendar. This began in Britain and her colonies on September 14, 1752. The area now forming the United States changed at different times depending on the colonial power; Spain and France had changed in 1582 and Russia had not changed by 1867 when Alaska was purchased by the U.S. from Russia.
It should be noted that, in this algorithm, the days on which the century, year, and month start are the "zeroth" day. This allows us to add the day of the month directly (without subtracting 1). For example, 1900 starts on day 0 which corresponds to a Sunday; however, we still need to add 1 for the 1 January which brings the day on which 1 January, 1900 fell to day 1, which is Monday, the correct day.
Now for an example of the complete algorithm, let's use April 24, 1982.
See also: ISO 8601Introduction
Put simply, using arithmetic modulo 7 means ignoring multiples of 7 during calculations. Thus we can treat 7 as 0, 8 as 1, 9 as 2, 18 as 4 and so on; the interpretation of this being that if we signify Sunday as day 0, then 7 days later (i.e. day 7) is also a Sunday, and day 18 will be the same as day 4, which is a Thursday since this falls 4 days after Sunday.
Some algorithms do all the additions first and then cast out sevens whereas others cast them out at each step. Either way is quite permissible; the former is better for when using calculators and in computer algorithms, the latter for mental calculation, since it is quite possible to do all the calculations in one's head with a little practice.Useful Concepts
Corresponding months
Note that May, June and August correspond with no other month. Also note that in the months table below, corresponding months have the same number, a fact which follows directly from the definition.Corresponding years
The Algorithm to Calculate the Day of the Week
Examples
Now let's try September 18, 1783.
Finally, let's try June 19, 2054Centuries Table
1752-1799 4
1800-1899 2
1900-1999 0
2000-2099 6
Months Table
January 0 (6 in leap year)
February 3 (2 in leap year)
March 3
April 6
May 1
June 4
July 6
August 2
September 5
October 0
November 3
December 5
Days Table
Sunday 0
Monday 1
Tuesday 2
Wednesday 3
Thursday 4
Friday 5
Saturday 6
References