Encyclopedia  |   World Factbook  |   World Flags  |   Reference Tables  |   List of Lists     
   Academic Disciplines  |   Historical Timeline  |   Themed Timelines  |   Biographies  |   How-Tos     
Sponsor by The Tattoo Collection
Calculating the day of the week
Main Page | See live article | Alphabetical index

Calculating the day of the week

This article details a mathematical algorithm to calculate the day of the week for any particular date in the past or future. 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
1 Introduction
2 Useful Concepts
3 The Algorithm to Calculate the Day of the Week
4 Another algorithm to calculate the day of the week
5 Calculating in your head
6 References

Introduction

The basis of all the algorithms to calculate the day of the week is:

  1. To number the days of the week from 0 to 6 so that we can then use arithmetic modulo 7 to add the number of days elapsed since the start of a known period (usually in practice a century).
  2. To look up or calculate using a known rule what day the given century started on.
  3. To look up or calculate what day the given year in that century started on.
  4. To look up or calculate what day the given month in that year in that century started on.
  5. To then add on the day of the month - this of course being the days elapsed since the month started.

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

'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:

Note that May and June 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

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 to Calculate the Day of the Week

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.

Examples

Now for an example of the complete algorithm, let's use April 24, 1982.

  1. Look up the 1900s in the centuries table: 0
  2. Note the last two digits of the year: 82
  3. Divide the 82 by 4: 82/4 = 20.5 and drop the fractional part: 20
  4. Look up April in the months table: 6
  5. Add all numbers from steps 1-4 to the day of the month (in this case, 24): 0+82+20+6+24=132.
  6. Divide the sum from step 5 by 7 and find the remainder: 132/7=18 remainder 6
  7. Find the remainder in the days table: 6=Saturday.

Now let's try September 18, 1783.

  1. Look up the 1700s in the centuries table: 4
  2. Note the last two digits of the year: 83
  3. Divide the 83 by 4: 82/4 = 20.75 and drop the fractional part: 20
  4. Look up September in the months table: 5
  5. Add all numbers from steps 1-4 to the day of the month (in this case, 18): 4+83+20+5+18=130.
  6. Divide the sum from step 5 by 7 and find the remainder: 130/7=18 remainder 4
  7. Find the remainder in the days table: 4=Thursday.

Finally, let's try June 19, 2054

  1. Look up the 2000s in the centuries table: 6
  2. Note the last two digits of the year: 54
  3. Divide the 54 by 4: 54/4 = 13.5 and drop the fractional part: 13
  4. Look up June in the months table: 4
  5. Add all numbers from steps 1-4 to the day of the month (in this case, 19): 6+54+13+4+19=96.
  6. Divide the sum from step 5 by 7 and find the remainder: 96/7=13 remainder 5
  7. Find the remainder in the days table: 5=Friday.

Centuries Table

1752-1799     4
1800-1899     2
1900-1999     0
2000-2099     6

Months Table

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

Days Table

Sunday 0
Monday 1
Tuesday 2
Wednesday 3
Thursday 4
Friday 5
Saturday 6

One can add constants (modulo 7) to these three tables provided the constant you add to the Day Table is equal to the sum of the constants you add to the Centuries Table and the Months Table modulo 7.

For example, the Another Algorithm shown next is equivalent to this algorithm, with a constant of 6 added to the Month Table and a constant of 1 added to the centuries table. Since 6+1=0 modulo 7 no constant is added to the Days Table.

Another algorithm to calculate the day of the week

This method is also valid for calculating days within the Gregorian calendar. Four numbers have to first be calculated to determine the day of the week, year, month, date and century value.

Year Value

1. For a given year the last two digits of the year are taken and divided by 4(multiples of 28 are taken from the year if it is greater than 28). 2. The quotent is then added too the two digits. 3. If the new number has decimal places, it is rounded down (multiples of 7 are taken from this new number to determine the year value).

Month Value

1. Each month is assigned a month value.

Jan		6
Feb		2
Mar		2
Apr		5
May		0
Jun		3
Jul		5
Aug		1
Sept		4
Oct		6
Nov		2
Dec		4

Date Value

1. To reduce the date value, multiples of 7 can be taken from it.

Century Value

The century value like the month values has a number assigned to it.

Calculation

  1. All for values are added together.
  2. At this point the number can be reduced by subtracting multiples of 7.
  3. The final number equals the day of the week. Monday being equal to 1 and
Sunday being equal to 7 or 0.

In the event of a leap year, 1 is subtracted from the total value if the month in question is either January or February.

Normally leap years occur every forth year, with the exception of years were the last two digits are 00 and, which aren't multiples of 400.

If the final value is negative or equal to zero seven is added until the number falls between 1 and 7.

Calculating in your head

An easy way to do the calculation in your head is to imagine the year starts on March 1 rather than January 1 (as it did in Roman times), so that the extra day in a leap year is the last day, rather than occurring in the middle of the year. That is, "day 0" described above is the last day of February.

April 4, June 6, August 8, October 10 and December 12 all occur on the same day as day 0 (note that April is the 4th month, June the 6th, August the 8th, etc).

May 9 and September 5 are also the same day as day 0 (May is the 5th month and September the 9th -- think of the Sheena Easton song "nine to five": the 9th day of the 5th month and the 5th day of the 9th month)

July 11 and November 7 are the same day as day 0 (the 7th and 11th months, respectively -- think of the "7-11" shops)

This day of the week is called Doomsday in the Doomsday algorithm, which uses these very same mnemonics. (copyright?)

However, if one regards the new year as beginning on 1 March one has a simpler situation for February and January. January 16 and February 6 are the same day of the week as the previous last day of February (i.e. last year's Doomsday) for every year.

Also within each year beginning 1 March, five months is always exactly 153 days and hence one day short of a whole number of weeks. This gives rise to the following dates on the same day of week stating with April 4, June 6 etc.

Month       +5 months    -5 months   +10 Months
April 4     September 5              February 6
June 6      November  7
August 8    January 9     March 7
October 10                May 9
December 12               July 11

So if you can figure out what day "day 0" is, you can quickly find a date in any month that falls on the same day, and you only have to add or subtract a few days to get to any other day in the month.

Memorise this: in 2000, day 0 was a Tuesday. Every century, day 0 changes according to the following pattern: Tuesday, Sunday, Friday, Wednesday, Tuesay, Sun, Friday, Wednesday, ... (mnemonic: "it's Too Sunny For Work" - "too" for Tuesday); i.e., in 2100 day 0 will be Sunday; in 1900 it was Wednesday. Every common year, day 0 moves forward one day, and two days every leap year; it moves ahead one day every 12 years (2000 is a Tuesday, 2012 is a Wednesday, 2024 is a Thursday, etc.)

So let's say you want to know what day June 3, 2017 will be. Day 0 for 2000 was a Tuesday, in 2012 it will be Wednesday, 2013 will be Thursday, 2014 Friday, 2015 Saturday, 2016 (a leap year) Monday, and 2017 Tuesday; June is the 6th month, so the 6th of June is a Tuesday. Three days earlier is Saturday.

References

See also: ISO 8601