Calculating the Day of the Week
Created | Updated Apr 6, 2009
You probably know what day it is today. Maybe your dustbin was emptied - so it must be a Tuesday, say - or did you check your newspaper? If you're reading this in the office, then you can probably gauge the proximity to Friday by the increasing levels of euphoria in those around you.
But what about dates in the recent past, or in the near future? If it's only a matter of days, then you can count off the weekdays in that familiar cycle of seven. For slightly longer gaps, you have to think about the different number of days in each month, but a reference like your calendar or diary will give you the answer. When you calculate across a number of years, you may have to consider leap years with an extra day. These days we have computers and PDAs to help us in these situations.
However, at some time or other you will be stranded without the use of these aids, wishing to know on which day of the week a particular event occurred or will occur - your 60th birthday, maybe, or D-Day in World War II - maybe it would settle a dispute at the pub. You'll be pleased to know that there is a formula, and it's not too difficult to learn. With practice, you'll find the calculation simple enough to do in your head, but you might like to use a pencil and paper while you hone your technique.
The Method
First, select the date of your choice. The formula works for dates in the modern Christian calendar, known as the Gregorian Calendar - we'll cover older dates later. We'll use as an example the date when Douglas Adams launched h2g2: 28 April, 1999.
Before you start
You will need to remember four numbers associated with this date. The day of the month (which we shall call D), the month (M), the two-digit year (Y) and the century (C).
In our example, D = 28, M = 4 (April), Y = 99 and C = 19.
Oh, there's one small complication here - our formula works on what are called 'March years' - years which begin in the month of March. If your chosen date is in January or February then you need to consider these as month 13 or month 14 in the previous year. For example, 27 February, 1961 would occur in the 'fourteenth' month of 1960, so its values would be D = 27, M = 14, Y = 60 and C = 19.
Step One
The first calculation is on the century, C. Divide it by four (ignoring the remainder), then subtract twice the century from this, and then subtract a further one from the result.
S1 = C/4 - 2*C - 1
In our example, S1 = 19/4 - 2*19 - 1, which comes to minus 35.
Remember this number - you'll need it later.
Step Two
Next we calculate using the year, Y. Multiply it by five, then divide it by four, again ignoring the remainder.
S2 = 5*Y/4
So we have: S2 = 5*99 / 4, which comes to 123.
You need to add this to the number you found in step one, and keep a running total.
We have minus 35 plus 123, which gives us 88.
Step Three
Add one to the month, M, multiply it by 26, then divide the lot by ten, ignoring the remainder.
S3 = 26*(M+1)/10
For our example we have 26 * (4+1) / 10, which comes to 13.
Once again, add this to our running total:
88 + 13 = 101.
Step Four
The easiest step - just add the day, D, to the running total:
S4 = D
101 + 28 = 129
Step Five
Divide our running total by seven, but this time we're only interested in the remainder. This will be a number between 0 and 6.
For our example: 129/7 = 18 remainder 3. Our result is 3.
Beware of negative numbers in this step. If you end up with a negative remainder, then you should add 7 to turn it into a positive remainder. So for example: -10 / 7 = -1 remainder -3. Add 7 to -3 to get the remainder 4.
Step Six
Convert this remainder into a day of the week, according to the following table:
Number | Weekday |
0 | Sunday |
1 | Monday |
2 | Tuesday |
3 | Wednesday |
4 | Thursday |
5 | Friday |
6 | Saturday |
So, in our example, h2g2 was born on ... a Wednesday!
The Complete Formula
Here it is all together. It may look daunting, but with a little practice, taking it one step at a time, most of us should be able to commit it to memory. The word TRUNC written around a division indicates that you should ignore the remainder. The word MOD7 indicates that you should take the remainder when the number is divided by 7. These words are short for 'truncate' and 'modulus' - the mathematical terms for those operations. WG means it's the weekday, using the Gregorian Calendar:
WG = MOD7 (TRUNC (C/4) - 2*C - 1 + TRUNC (5*Y/4) + TRUNC(26*(M+1)/10) + D)
Things To Do With It
OK, it's unlikely to be the most useful skill you ever acquired, but as well as giving your grey matter a workout, the following uses might occasionally arise:
Your Birthdate
Using your birthdate, find out whether you've turned out as predicted by this ancient nursery rhyme:
Monday's child is fair of face.
Tuesday's child is full of grace.
Wednesday's child is full of woe.
Thursday's child has far to go.
Friday's child is loving and giving.
Saturday's child works hard for a living,
But the child who is born on the Sabbath Day
Is bonny and blithe and good and gay.
Dates From History
We previously mentioned D-Day, so why not learn a few items of trivia by calculating the days of historical events. Some examples are given below - the answers are in footnotes, in case you get stuck.
The death of Elvis Presley, on 16 August, 19771.
The first episode of Coronation Street, aired on 9 December, 19602.
The sinking of the Titanic, on 15 April, 19123.
Credit Where It's Due
For this formula, we are indebted to the 19th-Century German clergyman and mathematician, Christian Zeller, who between 1882 and 1886 wrote a number of papers detailing calculations for both the day of the week and the date of Easter Sunday.
Zeller's formula recognises a mathematical pattern in the number of days in each month, but it's not something which is apparently obvious - we tend to use mnemonic rhymes to help us remember these, such as the following:
Thirty days hath September,
April, June, and November;
All the rest have thirty-one
Excepting February alone,
Which hath twenty-eight days clear
And twenty-nine in each leap year.
February is the exception, having two or three days fewer than the other months. Zeller's formula puts February at the end of the year, so that the number of days in each month of a March year becomes 31 - 30 - 31 - 30 - 31 - 31 - 30 - 31 - 30 - 31 - 31 - 28 (or 29). The first five months, March to July, are long-short-long-short-long. The next five, August to December, repeat this pattern, which begins again in January only to break off in February.
When we calculate the weekday for a date within the year we're only interested in the lengths of the months which come before it, so the number of days in the final month (now February) is immaterial. Zeller just needed to find a mathematical way to represent that pattern of 30s and 31s, and he realised that it was the same as the pattern you get when you multiply the month number by 2.6, ignoring the decimal. This goes 2, 5, 7, 10, 13, 15, 18, 20, 23, 26, 28... If you take the remainder when you divide these by seven, then it is the same remainder when you add the number of days in each month from the beginning of the year. This is the reason for the TRUNC (26*(M+1)/10) expression which we use in step three of the formula. It's fiendishly clever.
Older Dates
Don't give me all that papal bull.
- Warren Mitchell, as the bigot Alf Garnett.
As we said earlier, this formula works for dates in the Gregorian calendar, which began on Friday 15 October, 1582. Introduced by Pope Gregory XIII in a 1582 papal bull4 known as Inter gravissimas, this decree recalibrated the calendar year with the seasons, by removing ten calendar days. The day before the calendar came into operation was Thursday 4 October: the last day of Julius Caesar's increasingly inaccurate Julian calendar, which had operated since 45BC. The papal decree also made other changes, in particular removing three leap years in every 400, in order to keep the calendar seasonally on track in the future.
Now, Gregory's calendar wasn't adopted universally from that point - in some non-Catholic countries it took hundreds of years before it was implemented. Britain for example, moved across in 17525, losing the dates between 3 September and 13 September inclusive. Today, some Orthodox churches still follow the Julian calendar for religious festivals.
If you are considering calculating the day of the week for older dates, then first be clear in which calendar the date is quoted. Gregorian dates use the formula which we have seen, but Julian dates need a little adjustment:
Formula for the Julian Calendar
WJ = MOD7 ( 5 - C + TRUNC (5*Y/4) + TRUNC (26*(M+1)/10) + D)
This formula's actually a little bit simpler, as it doesn't require the Gregorian leap year corrections. The only change is in Step 1, which you calculate by subtracting the century from five:
S1 = 5 - C
Everything else is unchanged, so follow Step 2 through to Step 6 as before.
And Finally - Some Tips for Faster Calculation
With practice, you will soon learn that there are patterns associated with some of the calculation steps. For every (Gregorian) date in the 1900s, step 1 calculates to be minus 35. For every date in the month of August, step 3 comes out as 23. In fact we're only ever interested in the remainder when the total is divided by 7, so you could replace minus 35 and 23 with simpler numbers having the same remainder: zero and two respectively in these examples.
If you're a regular weekday calculator and you would like to save a little time, then go ahead and learn the values in these tables:
Quick Values for Step 1 (Gregorian Calendar)
Century | Step 1 | Number to learn |
1500s | minus 28 | 0 |
1600s | minus 29 | 6 |
1700s | minus 31 | 4 |
1800s | minus 33 | 2 |
1900s | minus 35 | 0 |
2000s | minus 36 | 6 |
2100s | minus 38 | 4 |
Quick Values for Step 1 (Julian Calendar)
Century | Step 1 | Number to learn |
1200s | minus 7 | 0 |
1300s | minus 8 | 6 |
1400s | minus 9 | 5 |
1500s | minus 10 | 4 |
1600s | minus 11 | 3 |
1700s | minus 12 | 2 |
Quick Values for Step 3 (Either Calendar)
Month | Step 3 | Number to learn |
March | 10 | 3 |
April | 13 | 6 |
May | 15 | 1 |
June | 18 | 4 |
July | 20 | 6 |
August | 23 | 2 |
September | 26 | 5 |
October | 28 | 0 |
November | 31 | 3 |
December | 33 | 5 |
January | 36 | 1 |
February | 39 | 4 |