How to calculate the day of any given date

The formula to calculate the day of any given year is given by the formula:

Day= (Year Code+ Month Code+ Century Code+ Date Number- Leap Year Code) MOD 7

For the next examples I’m going to use my birthday, which is the 31st May, 2004.

NOTE:
INT means integer, which means if there is a decimal number, then get rid of the number after the decimal point.
MOD means modulo, meaning divide the number and only take into account the remainder. This is represented by the sign % sometimes.

To calculate the Year Code:
Take the last 2 digits of the year as YY. The formula goes like this:

INT(YY + (YY/4)) MOD 7

So for my example, it will be (04+ (04/4)) =5, modulo 7. 5 % 7= 5

To calculate the Month Code:
Just remember 033614625035:
January = 0
February = 3
March = 3
April = 6
May = 1
June = 4
July = 6
August = 2
September = 5
October = 0
November = 3
December = 5

For my example, it will be 1

To calculate the Century Code:
You need to decide if the year is before 1752 or after it. At the time, they were changing from a Julian Calendar to a Gregorian calendar.

If it is after 1752:
1700s- Add 4
1800s- Add 2
1900s- Add 0
2000s- Add 6
2100s- Add 4
2200s- Add 2
2300s- Add 0

Basically, remember 420,6,420. In my example it will be 6,as it is in the 2000s.

If it is before 1752:
Take the century number and subtract 18 from it, then modulo 7 to it.
For some reason, if the year is around 1500-1700, you need to add 4 to the number, otherwise it will be the wrong day.
So for example, 802 AD will be 18-8= 10, 10 % 7 which is 3.

To calculate the Date Number:
Just get the date number from the date.

In my case, it would be 31.

To calculate the Leap Year Code: (Only applies to January or February)
Again, if it is the Gregorian Calendar (After 1752), follow the leap year rules:

If the year is divisible by 4, it is a leap year, so subtract 1.
If the year is divisible by 100, it is not a leap year.
If the year is divisible by 400, it is a leap year.

In our case, 2004 is a leap year, but it is in May, so there is no change and the number is 0

If it is a Julian calendar, it’s simple, if the number is divisible by 4, it’s a leap year, thus subtracting 1.

So then, add up all of the codes and modulo 7 to it. In my example:

(5+1+6+31+0) % 7 = 1
Then you use the following code:
0 = Sunday
1 = Monday
2 = Tuesday
3 = Wednesday
4 = Thursday
5 = Friday
6 = Saturday

So this shows that the 31st May, 2004 is a Monday, and it is correct.

More Examples

The Battle of Adrianople was on the 9th August, 378 AD. Using the code, I found out that:

Day= (6+2+6+9+0) % 7 = 6, which was on a Saturday. I was confirmed this is correct.

The end of the First Siege of Vienna was on the 15th October, 1529.

Day= (1+0+0+15+0) % 7 = 2, which was on a Tuesday- This is correct.

Does it always work? Not really. I worked out the date of 14th February, 1496. The formula gives:
Day= (1+3+1+14-1) % 7 = 4, which is on a Thursday.

Trouble is, the calendar app says it’s on a Sunday.
Alexa said the day was on a Friday.
Siri insisted Valentine’s Day was on the 22nd February and told me it was on a Thursday, but working down says it’s on a Saturday. Who’s right? I don’t know.

4 Likes

Great first post, Ryan!

There have already been some posts about calendar calculations. These may interest you too for comparison:

https://forum.artofmemory.com/search?q=calendar%20calculations%20category%3A20

1 Like

You should really connect those statements with unless and except between first and second and second and third statement, respectively.

1 Like