h1

How to Determine Day of the Week for Any Year

October 15, 2011

The day of the week calculation is at 7:55

Would you like to be able to accomplish such a feat? Most of us are not concerned with mathemagic – we just want to get the data asap. To carry out the calculations for a year with a known number, you just have to memorize a couple of small tables and understand the algorithm. For a wonderful comprehensive explanation, examples, and quizzes, visit the Grey Matters. The following is just an attempt to concisely summarize the algorithm and provide additional examples, as well as some tables.

To learn the method you’ll need to:

- Memorize Table 1 and Table 2
– Refer to Table 5 for the code of the years of interest
– Understand the algorithm for the calculation


Step 1: Day

f(x)=\Biggl\{\begin{array}{cl}  x & x<7\\  0 & 7\leq x\leq31,\, x\equiv0(mod\,7)\\  x\, mod\,7 & else\end{array}

Case 1: If a day is less than seven, take a day as is.
Example: {1, 2, 3, 4, 5, 6} => {1, 2, 3, 4, 5, 6}

Case 2: If a day is a multiple of seven, take zero
Example: {7, 14, 21, 28} => {0}

Case 3: If a day does not fit under Case 1 or Case 2, take a difference between a day and a closest integer divisible by 7

Examples:

Day = 15th, Day Code = 15 – 14 = 1
Day = 26th, Day Code = 26 – 21 = 5
Day = 31th, Day Code = 31 – 28 = 3


Day Code
Sunday 0
Monday 1
Tuesday 2
Wednesday 3
Thursday 4
Friday 5
Saturday 6
Table 1. Days

Step 2: Month

Note that in leap years you’ll have to subtract one from January and February code. Leap years in the 21st century are highlighted in Table 5. For example in 2012, January will be counted as 5 instead of 6, and February will be counted as 1 instead of 2.


Month Code
January 6
February 2
March 2
April 5
May 0
June 3
July 5
August 1
September 4
October 6
November 2
December 4
Table 2. Months

Step 3: Year

Determine the year code either from a table or by a method described in the next section.

Step 4: Day of the Week Calculation

Day of the Week Code = Day Code + Month Code + Year Code

Examples:

2011 December 31

Step 1 Day: 31 – 28 = 3
Step 2 Month: December is 4
Step 3 Year: 2011 is 6 (or -1)
Step 4 Calculation: 3 + 4 + 6 = 13 – 7 = 6
Answer: Saturday

2012 January 23 (Lunar New Year)

Step 1 Day: 23 – 21 = 2
Step 2 Month: January is 6, but 2012 is a leap year, so take 5
Step 3 Year: 2012 is 1 (see Table 4)
Step 4 Calculation: 2 + 5 + 1 = 8 – 7 = 1
Answer: Monday

Calculating Year Code

Calculating the year number will require some more memorization.


Year Code
2000 0
2004 5
2008 3
2016 6
2020 4
2024 2
Table 3. First 7 Leap Years

Year Code
2012 1
2024 2
2036 3
2048 4
2060 5
2072 6
2084 7 => 0
2096 8 => 1
Table 4. Year Multiples of 12

2000-2027

Rule: Calculate based on adjustment to the memorized Tables 3 or 4

Examples:
2019. 2016 = 6 => 2019 = 6 + 3 – 7 = 2
Alternatively, 2019. 2020 = 4 => 2019 = 4 – 2 = 2
2026. 2024 = 2 => 2026 = 4

2028-2052

Rule: Subtract 28

Example: 2036-2028 = 2008 => 3 (by Table 3)

2056-2080

Rule: Subtract 56

Example: 2069-2056 = 2013 => 2 (2012 = 1)

2084-2096

Rule: Subtract 84

Example: 2090 – 2084 = 2006 => 0 (2004 = 5)

Other Centuries

2300-2399: + 1
2200-2299: + 3
2100-2199: + 5
2000-2099: + 0
1900-1999: + 1
1800-1899: + 3
1700-1799: + 5
1600-1699: + 0

Example:

1777 April 30
Step 1 Day: 30 – 28 = 2
Step 2 Month: April is 5
Step 3 Year: 77 – 56 = 21 => 5 (+ 5, adjusting for the century) = 10
Step 4 Calculation: 2 + 5 + 10 = 17 – 14 = 3
Answer: Wednesday

Table 5. The 21st Century

Year Code Hint
2000 0
2001 1
2002 2
2003 3
2004 5 4+1=1
2005 6
2006 0
2007 1
2008 3
2009 4
2010 5
2011 6
2012 1 12×1=12
2013 2
2014 3
2015 4
2016 6
2017 0
2018 1
2019 2
2020 4
2021 5
2022 6
2023 0
2024 2 12×2=24
2025 3
2026 4
2027 5
2028 0 28-28=0
2029 1
2030 2
2031 3
2032 5 32-28=4
2033 6
2034 0
2035 1
2036 3 36-28=8
2037 4
2038 5
2039 6
2040 1 40-28=12
2041 2
2042 3
2043 4
2044 6 44-28=16
2045 0
2046 1
2047 2
2048 4 12×4=48
2049 5
2050 6
2051 0
2052 2 52-28=24
2053 3
2054 4
2055 5
2056 0 56-56=0
2057 1
2058 2
2059 3
2060 5 12×5=60
2061 6
2062 0
2063 1
2064 3 64-56=8
2065 4
2066 5
2067 6
2068 1 68-56=12
2069 2
2070 3
2071 4
2072 6 12×6=72
2073 0
2074 1
2075 2
2076 4 76-56=20
2077 5
2078 6
2079 0
2080 2 80-56=24
2081 3
2082 4
2083 5
2084 0 12×7=84
2085 1
2086 2
2087 3
2088 5 88-84=4
2089 6
2090 0
2091 1
2092 3 92-84=8
2093 4
2094 5
2095 6
2096 1 12×8=96
2097 2
2098 3
2099 4

Please note that this is just one way of calculating weekdays, among many other algorithms.

About these ads

2 comments

  1. Or you could just look it up on online :)



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 93 other followers

%d bloggers like this: