Copyright © 2003
Page last modified:
Get Microsoft Internet Explorer
This page uses MSIE4+ features
How to do quick date calculations using the Gregorian calendar

uite often you know the date of some event and you want to know what day of the week it is or was. Well, this page provides you with an easy method for calculating just that, without the help of anything else but your own brain! You only have to memorise a few simple rules which are given below. But first, I'll explain the Gregorian calendar and the fundamentals of this method.

What is the Gregorian Calendar?
To explain this, we'll have to go a bit further back into history, since it succeeded the Julian Calendar, which was introduced by Julius Caesar. It was one of the early attempts to make an accurate calendar that would last for many centuries. By then, it was known that the length of the year was a bit more that 365 days. With the accuracy then achievable, some wise men noticed a shift of 1 day every 4 years. Julius Caesar introduced a calendar that included 1 extra day every 4 years to compensate for this shift, so that the seasons would not shift away from predefined dates (such as 21 March for the beginning of spring). We still know this system today: we have a leap year every 4 years, haven't we? (No, we haven't, see below).

But when time progressed and the centuries passed by, it became apparent that this calendar was not so accurate as people wanted. In the 16th century, the error had accumulated to 10 whole days! This means that spring no longer began on the 21st of March but on the 11th, and thus the date of Easter was no longer correct! Pope Gregory XIII then decided that a revison of the calendar was necessary. The astronomers Lilius and Clavius had computed that there had been 3 leap days too many every 400 years. This led to the following correction:

  • The leap year schedule of one leap year every 4th year was changed so that years that are a multiple of 100 are no longer a leap year unless it can be divided by 400. So 1600 was a leap year, but 1700, 1800, 1900 were not, and 2000 was again a leap year, 2100 will not be a leap year, etc. This was the necessary correction of 3 days per 400 years.
  • The error of 10 days was corrected by simply skipping 10 dates: they jumped directly from Thursday 4 October 1582 to Friday 15 October 1582.
Click on the image for an enlargement.
It is the first page of the papal bull "Inter Gravissimas", by which Pope Gregory XIII introduced his calendar.
See also (which is where I downloaded the image).

So, summarising the Gregorian Calendar:

  • Every year that can be divided by 4 is a leap year, except the century changes, which are only leap years if they are a multiple of 400.
  • Each year has 12 months as follows:

     no.   month   days 
     1:   January   31 
     2:   February   28 (29 in leap years) 
     3:   March   31 
     4:   April   30 
     5:   May   31 
     6:   June   30 
     no.   month   days 
     7:   July   31 
     8:   August   31 
     9:   September   30 
     10:   October   31 
     11:   November   30 
     12:   December   31 

This means that the calendar has a cycle of 400 years as far as leap years are concerned. Every 400 years the same leap year schedule appears. During that cycle, 97 leap years occur (once every 4 years except 3 century changes, so 400 / 4 - 3 = 97). By pure coincidence, this happens to be just an integral number of weeks as well This means that every 400 years the Gregorian calendar repeats itself exactly on the same days of the week! This property of the Gregorian Calendar will be used for the quick calculation method to determine the day of the week for any date.

Some more interesting details of the calendar
Another thing we will use is the following remarkable property of the schedule of the months within the year. Look at the following: April + May have 61 days, June + July have 61 days, August + September have 61 days, and October + November have 61 days.

This means that from X April to X+2 June is 63 days or exactly 9 weeks, so X+2 June is the same day of the week as X April. Always. And in the same way, by advancing 2 months and 2 days, X+4 August is also the same day of the week. Always. Every year. And X+6 October is too, as well as X+8 December. Each and every year! Now let's take X = 4. Then we see the following: 4/4, 6/6, 8/8, 10/10, and 12/12 are all on the same day of the week! Every year. Always. No exception. We'll call the day on which these dates fall the reference day of the given year.

Now we are nearly there! If we can find an easy way to calculate what day of the week it is for a given year, then we have 5 reference points in the year from where we can easily count forward or backward to the given date for which we want to know the day of the week.

There's one other property of the calendar we will use. Have you ever noticed that your own birthday advances 1 day every year? And that it advances 2 days if there is a leap day in between? This 1 day advance per year has a simple cause: a year has 52 weeks plus 1 day, since 52 x 7 = 364. That one day (plus an extra day every leap year) is precisely the advance that your birthday or any date makes every year.

Finding the day of the week for a given date
Now suppose we know what weekday the reference day is in the first year of a century (i.e. in year xx00, in this context centuries begin in 100-fold years - no discussion!). Then we must advance 1 day for every year thereafter plus 1 day for every 4 years in between, so we simply add the year number (only the 2 digit number within the century) plus the same 2-digit year number divided by 4 (rounded down), so for the year xxyy we will add yy + [yy DIV 4]. (DIV is integer division ignoring any remainder).

We must still find the reference day of the year xx00. Therefore we will use the 400-year cycle of the Gregorian Calendar, so we only need to memorise 4 numbers for the repeating schedule of 4 centuries. And it appears to be easy.

But first, a definition is made for numbering the days of the week. Since the last step of our calculation will be the remainder of a division by 7, the days will be numbered from 0 to 6, starting with Monday and ending with Sunday. It should be obvious that adding (a multiple of) 7 to the result still yields the same day of the week, so instead of let's say day number 1 for Tuesday we can just as well use number 8 for the same day (and we will do that below, because it's easier to memorise).

Now let's determine the reference days of the xx00 years. Using any perpetual calendar available on the web (for example this one, or click on a century number in the table below), we can check 4 consecutive centuries, giving the following result:

 year  reference day  day number 
 1600  Tuesday   8 
 1700  Sunday   6 
 1800  Friday   4 
 1900  Wendesday  2 

This schedule repeats every 400 years, so within each 4-century block the centuries have a reference day of 8, 6, 4, and 2 respectively. When you read the previous sentence just once again you'll never forget these simple numbers anymore! I told you it was easy!

Step by step calculation of the reference day of a year
After the explanation above, finding the reference day of a given year can be collated as follows:

  1. Represent the year using the format mask "ccyy" (where "cc" is the first 2 digits of the year and "yy" are the last 2 digits).
  2. Split this into "cc", the century offset, and "yy", the 2-digit year within the century.
  3. Determine in what century of the 4-century Gregorian cycle the value "cc" lies and take the corresponding initial reference day from the table below:

     cc  day of week 
     16, 20, 24, etc.  8 
     17, 21, 25, etc.  6 
     18, 22, 26, etc.  4 
     19, 23, 27, etc.  2 

  4. Add the value "yy" to this number.
  5. Also add the value of "yy" DIV 4 (DIV is integer division ignoring any remainder).
  6. Divide this result by 7 and use only the remainder.
  7. Translate this remainder to a day as follows:

     remainder  day of week 
     0  Monday 
     1  Tuesday 
     2  Wednesday 
     3  Thursday 
     4  Friday 
     5  Saturday 
     6  Sunday 

The day thus found is the reference day of the given year, so 4/4, 6/6, 8/8, 10/10, and 12/12 of the given year are all on this day of the week.

Finding other dates than 4/4, 6/6, 8/8, 10/10, or 12/12
For dates within the months numbered 4, 6, 8, 10, or 12 that should be easy! For March, May, July, September, and November the easiest way is to use the reference date of the succeeding month.

For example: suppose we want to know on what day the 15th of March 2003 Using the method above you can find that 2003 is a "Friday year", so 4/4 is a Friday. But the 4th of April can also be interpreted as 35 March, can't it? (This may seem odd, but for the purpose of calculation it's absolutely perfect!). And if 35 March is a Friday, then the 14th of March is too, since that's exactly 3 weeks earlier. Then the 15th of March is a Saturday. Bingo!

For the other months it's done in the same way.

What about January and February?
Because February hasn't got 30 days, 2/2 is not on the reference day of the year, so we must use something else. But it's not so difficult. By counting back from 4/4, we can determine that 0 (zero) March (which of course is the last day of February) is on the reference day. So that is either the 28th or the 29th of February. And in non-leap years February is identical to March! Through February it is easy to count back into January. In non-leap years, 0 February is on the reference day, in leap years 1 February is on the reference day. And, of course, 0 February = 31 January and 1 February = 32 January.

Putting it all together
In a more mathematical approach, we can summarise the algorithm as follows, where DIV means integral division ignoring any remainder and MOD is an operator that returns only the remainder of a division.

The rules below are so simple that you should be able to memorise them quite easily. I could, so why not you? As an aid for training your brain, I've added a calculator (using MSIE4+ features). The random date button generates a date between 1600 and 2400. When you use the calendar button, automatic switching between the Julian and Gregorian calendar is performed (the date is converted to Gregorian when you select it).

  ccyy  -  mm  -  dd  
    -   -       

Step 1: determine the reference day of the year:

  C = year DIV 100     century offset      
  if C in (16,20,24,etc.) then X = 8  
  if C in (17,21,25,etc.) then X = 6  
  if C in (18,22,26,etc.) then X = 4  
  if C in (19,23,27,etc.) then X = 2  
  base value for the date's century      
  Y = year MOD 100     2-digit year within the century      
  Z = Y DIV 4     no. of leap days since 1 March xx00      
  S = X + Y + Z     base value + 2-digit year + leap days      
  D = S MOD 7     the reference day      
  0 = Mon, 1 = Tue, 2 = Wed, 3 = Thu, 4 = Fri, 5 = Sat, 6 = Sun      

Step 2: determine the weekday of the given date:
Find the nearest date in the following table and then count back or forward to the date for which you want to know the weekday. The following dates are always on the reference day:

 in "normal" years:  0 February, 0 March, 4/4, 6/6, 8/8, 10/10, and 12/12 
 in leap years:  1 February, 0 March, 4/4, 6/6, 8/8, 10/10, and 12/12 

Now take the challenge and memorise these simple rules, then you can impress your friends and colleagues by using mental arithmetic!

Another nice website, Doomsday algorithm for Day of Week, gives the following simple rule for the odd-numbered months: for long odd months (identified by month number N), the reference day is the (N + 4)th, while for short odd months, the reference day is the (N - 4)th. The mnemonic is: long = add, short = subtract. Thus

3  = March  (long  = add),  +  4 =  7th is reference day
5  = May  (long  = add),  +  4 =  9th is reference day
7  = July  (long  = add),  +  4 =  11th is reference day
9  = September  (short = subtract),  -  4 =  5th is reference day
11  = November  (short = subtract),  11 -  4 =  7th is reference day

For January you could add the following: you could count that as a short 13th month of the previous year. Then for January, the 13 - 4 = 9th is on the reference day of the previous year.

In this table you can see (as is also stated on the Doomsday algorithm for Day of Week website), that 5/9 and 9/5 are on the reference day, and the same applies to 7/11 and 11/7. Maybe you find that easier to memorise.

Personally I prefer to calculate into the odd months using an even month as a starting point. Either by using the next month as described above, or by using the previous month as follows: going to the same date in the next month advances by 2 days if the starting month is short and by 3 days if the starting month is long (because 30 MOD 7 = 2 and 31 MOD 7 = 3). For example: to determine a date in May, I use 4/4 as a starting point. Going to the same date in May means advancing 2 days. In 2003 the reference day (so 4/4) is a Friday, then the 4th of May is 2 days later, e.g. a Sunday.

I think the rules to be memorised should be as brief as possible, and I simply presume that the lengths of the months are already known to everyone. Then you have to memorise only this.

Dates on the Julian calendar
As already mentioned, the Gregorian calendar was introduced on Friday 15 October 1582. One day earlier it was Thursday 4 October on the Julian calendar. Not all countries took up this calendar change immediately, some countries (like Russia and Greece) didn't change before 19xx (that's why Russia's October Revolution took place in November [24+25 October 1917 on the Julian calendar to be precise] ). Before 15 October 1582, all dates are Julian. As described above, the difference between the two is that the Julian calendar has leap years EVERY 4 years, whilst the Gregorian calendar excludes 3 of every 4 century changes from being a leap year. Every century change that is a Julian leap year but not a Gregorian leap year increments the difference by one day. The original skip was 10 days, since then there have been 3 such century changes (1700, 1800, 1900), so currently the difference is 13 days.

Look here to see when different countries changed to the Gregorian calendar.

Converting a date from Gregorian to Julian is done as follows (of course there are many more methods - maths is nice and flexible...):

  • Use the century offset C already calculated, and subtract C - 2 - (C DIV 4) days from the Gregorian date (using Julian leap days if applicable and for January and February of the cc00 years, you must use the previous century).

Converting from a Julian date to Gregorian is done by adding the number of days instead of subtracting (also using Julian leap days and if it jumps to or over a Julian leap day that is not a Gregorian leap day you should add one more day).

The table below lists some of the day counts to be added or subtracted for a wide range of centuries:

With a little bit of training, you should be able to do this by mental arithmetic (do not memorise the table, but the algorithm!).

For determining the weekday of a date on the Julian calendar, you only need to convert the date to Gregorian by adding the proper number of days and then use the above method to find out the day of the week of this Gregorian date. The 4-century cycle of the Gregorian calendar can simply be extrapolated to earlier centuries, so for example 800 and 1200 are also "Tuesday years", just like 1600 and 2000.

But maybe you find this easier: Julian centuries are always 100 * 365 (days per year) + 25 (leapdays) = 36525 days long, which happens to be 5218 weeks minus 1 day. So every Julian century the reference day of the cc00 year is one day earlier. For example: Julian 1300 was a Monday year, Julian 1400 was a Sunday year, Julian 1500 was a Saturday year, etc. This makes it easy to calculate the reference day of a Julian century year. It is:

6 - CC MOD 7

Look here to memorise the simple calculation method for Julian dates.

If you have a date and you don't know whether it is on the Julian or on the Gregorian calendar, check here when various countries changed from Julian to Gregorian. This web page always uses 15 October 1582 as the switch date from Julian to Gregorian.

You can use this Julian/Gregorian convertor to check your mental arithmetic:
ccyy - mm - dd  
- -  
  ccyy - mm - dd
  - -

New Year's Day and the A.D. year numbering
Another thing that is important to know is the fact that New Year's Day has not always been the 1st of January. So for correct historic surveys, you must also find out when New Year's Day was at the given time in the given country and correct the year number as applicable. See this example, which I have copied from Claus Tøndering's Calendar FAQ.

Furthermore you need to know that the A.D. year numbering was not introduced until A.D. 525 by Dionysius Exiguus, before A.D. 525 they actually used a different way of counting years.

The Julian calendar was introduced in 45 BC (which mathematically should be year -44) and in the first few decennia thereafter they made a stupid mistake in the leap years. Since A.D. 8 the leap years have followed the proper schedule without exception, but February might have been the last month of the year in some countries during some period.

Other interesting web sites
The internet contains lots of information about calendars and calendar calculations. This info is much better accessed via the regular search engines then by some hardcoded links. Therefore I list just the following:

About this same subject:

(but I persist that my method is the easiest to memorise).

About calendars in general:

(End my specially thanks going to Antony Heywood four he corrected every thing I did wrote with errors in English)

Copyright © 2003

P.S.   I have not yet fully debugged all JavaScript code on this page. I would appreciate if you notify me of any errors you might find.