# How to Calculate the Day of the Week from Any Date

Here is a calendar calculation technique that I learned from a book called Mind Performance Hacks. It allows you to take a date, like 14 March 1987, and mentally calculate which day of the week it fell on.

Just click the "Sign up" button below to create an account, and we'll send you a free ebook with tips on how to get started with memory techniques and mental calculation.

## The Formula

The formula is:

(Year Code + Month Code + Century Code + Date Number – Leap Year Code) mod 7

## Here’s How it Works

I’ll run through an example with the date, 14 March 1897 — Einstein’s birthday.

### The Year Code

To calculate the Year Code, use this formula:

(YY + (YY div 4)) mod 7

YY is the last two digits of the year. For the year 1897, it’s 97.

First, divide YY by 4 and discard the remainder: 97 div 4 = 24.

Then add 24 back into the YY number, which is 97 in this case, resulting in 121.

The next step is: 121 mod 7.

Mod” means to divide the number and keep only the remainder. For 121 mod 7, start removing sevens:

• 10 x 7 is 70, leaving us with 51, because 121 – 70 = 51.
• 7 x 7 = 49, and 51 – 49 = 2.

We’ve removed all the sevens from 121 until we are left with a remainder of 2. That is the Year Code for 1897.

You could use a number shape image like a swan to hold that in memory while you calculate the items below.

### The Month Code

This is easy — just memorize the number 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

Now you have the Month Code. For Einsteins birthday in March, it is 3.

#### A Quick Note on Memorizing Numbers

If you don’t know how to memorize a number like 033614625035, you could either use repetition or learn a mnemonic system like the Major System or Dominic System. I use my Ben System images: Samwise (033) throws a glass of beer (614) on George Boole (625) who falls backwards on Sally (035).

A way to quickly memorize 033614625035 without a complex mnemonic system would be to use a number shape system to associate images with each month. For example, you could picture a game of soccer (football) in January, with ball being a mnemonic image for zero. You could picture a butterfly in February and March, if you use a butterfly image for the number three. If the number six is represented by the image of an elephant, picture an elephant in April and July, and so on. If you are having trouble associating the images with the months, pick an aspect of each month to associate the image with. For example, Halloween is in October, so to remember that October has a Month Code of zero (represented by an image of a ball), you could picture a group of people in Halloween costumes doing something with a ball. That would link the month of October with the number zero.

### The Century Code

You then need to apply an adjustment based on the century. In Great Britain, and what was to become the USA, the calendar system changed from the Julian Calendar to the Gregorian Calendar on 2 September 1752. The Gregorian Calendar began on 14 September 1752, skipping 11 days.

#### Gregorian Dates

For the Gregorian Calendar, remember the number 4206420:

• 1700s = 4
• 1800s = 2
• 1900s = 0
• 2000s = 6
• 2100s = 4
• 2200s = 2
• 2300s = 0

If you are only doing this calendar trick with friends’ birthdays, you could probably leave this step out, because dates that fall in the 1900s get a Century Code of zero and don’t affect the outcome of the calculation.

#### Julian Dates

If you are looking at a Julian date, the formula is to take the century number and subtract it from 18 and then mod 7.

Example 1: if the year is 852 CE, take the century number, 8, and subtract it from 18, leaving 10. Then, 10 mod 7 =3.

Example 2: if the year is 1625 CE, take the century number, 16, and subtract it from 18, leaving 2. 2 mod 7 = 2, so in this case the Century Code is 2.

For Einsteins birthday in 1897, the Century Code is 2, because it’s a Gregorian date, and the chart above shows that dates in the 1800s get an adjustment of 2.

### Leap Year Code

The other thing to take into account is whether you are dealing with a leap year. EDIT: If the date is in a January or February of a leap year, you have to subtract one from your total before the final step.

#### Gregorian Calendar

If you can divide a Gregorian year by 4, it’s a leap year, unless it’s divisible by 100. But it is a leap year if it’s divisible by 400.

1992 is a leap year because you can divide it by four.
1900 is not a leap year because you can divide it by 100.
2000 is a leap year because you can divide it by 400.

#### Julian Calendar

If you can divide a Julian year by 4, it’s a leap year.

Einstein’s birthday was in 1897 which was not a leap year (0), so it doesn’t affect the outcome.

## Calculating the Day

Back to the original formula:

(Year Code + Month Code + Century Code + Date Number – Leap Year Code) mod 7

For 14 March 1897, here are the results:

• Year Code: 2
• Month Code: 3
• Century Code: 2
• Date Number: 14 (the 14th of the month)
• Leap Year Code: 0

So:

(2 + 3 + 2 + 14) mod 7 = 21 mod 7 = 0

Match the resulting number in the list below, and you’ll have the day of the week:

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

Einstein was born on a Sunday.

## More Examples

Here are three more examples from different centuries:

### The Moon Landing

Humans set foot on the moon: 20 July 1969:

• Take ’69 and divide by 4, discarding the remainder. That leaves 17. Add 69 to 17 to get 86. Then, 86 mod 7 = 2. The Year Code is 2.
• The Month Code for July is 6.
• The Century Code for the 1900s is zero.
• The Date Number is 20, because it’s the 20th of July.
• 1969 wasn’t a leap year since it can’t be divided by 4.
• 2 + 6 + 0 + 20 = 28
• 28 mod 7 = 0

20 July 1969 was a Sunday.

### The Battle of Hastings

The Battle of Hastings took place on 14 October 1066.

• Take ’66 and divide by 4, ignoring the remainder: 16. Add 66 to 16 to make 82. 82 mod 7 makes a Year Code of 5.
• October has a Month Code of zero.
• The Day Number is 14.
• The Century Code for this Julian date is 18 – 10 = 8. 8 mod 7 = 1.
• 1066 was not a leap year.
• Answer: 5 + 0 + 14 + 1 = 20. 20 mod 7 = 6

14 October 1066 was a Saturday.

### Beginning of the 21st Century

1 January 2000:

• January has a Month Code of zero.
• The Day Number is 1.
• The Century Code for dates in the 2000s is 6.
• 2000 is a leap year, since it can be divided by 400, and the date is in a January or February, so subtract 1 from the total in the final step.
• Answer: 0 + 0 + 1 + 6 – 1 = 6.

1 January 2000 was a Saturday.

If you have any questions, please leave a comment below. There are also some shortcuts and tips in the Mentat Wiki — scroll down to the section titled, “The Classic Formula”.

• Renee

This has a very practical application. I use this technique at my job while recording labs and writing medication orders.

• Pavkata

When i calculate the The Moon Landing with the julian calendar the result is Monday.
The difference comes from the century code. Am i wrong?

• For any date in the 1900s, the Century Code is zero. If you change that number, you won’t get the same answer — or are you asking something different?

• Sorry, I made a mistake in the post. You only subtract 1 in a leap year if the date is in January or February. I’ve updated the post.

• Robert

please what if the year is1902 or 1905, how will you get the year code when you are to divide by 4

• Bhupesh

I am trying to calculate 15/jan/2004..

Take 04 and divide by 4, ignoring the remainder: 01. Add 04 to 01 to make 05. 05 mod 7 makes a Year Code of 00.
Jan has a Month Code of zero.
The Day Number is 15.
The Century Code 6
2004 is a leap year.
Answer: 0 + 0 + 15 + 6 – 1 = 23. 20 mod 7 = 6

6 Means Saturday ….. But as per Calendar on 15/Jan/2004 day was Thursday …

Am I doing something wrong here ??

Bhupesh

• @Robert:
For 1902: (02 + (02 div 4)) mod 7 = (2 + 0) mod 7 = 2
The fraction, 2/4, is dropped.

So:
1901 = 1
1902 = 2
1903 = 3
1904 = 5

@Bhupesh:
5 mod 7 = 5
http://www.wolframalpha.com/input/?i=5+mod+7

See if it works with that change.

5/12/2015?? if i calculate,the day wil come as a wrong.

• It works for me. Try again and if it still doesn’t work, post all the steps of your calculation in a comment here.

• Ritvij Kumar Sharma

What is the logic of finding the month code and century code?

• I don’t know the math explanations behind the technique, but if you ask that question in the forum, someone may be able to answer that question. (I suspect that Kinma or GreyMatters would know.)

• Shankar

Pls explain logic of the month code

• Sudhakaran Puthiyapurayil

14 March 1987
Sir,
There is no need to do that much calculation. 20th century ( AD 1900 Jan 1st was on Monday.
1901 Jan 1st on Tuesday, 1902 Jan 1st on Wednesday and 1903 Jan 1st on Thursday. Each year will
be repeated after 28 years. Here it will be repeat three times. 1903+28+28+28=1987
1987 Jan1st was Thursday. May 1st Friday, Aug 1st Saturday and Mar 1st Sun day. Mar 8th and 15th
also Sunday. So, 14 march 1987 was on Saturday.

• Sudhakaran Puthiyapurayil

Each century starting in a particular days. If 20th century starting on Monday the 18th century on Friday. It was worked out myself. I prepared such book from it we can find out any day and date up to
AD 4000 within seconds ( 41st Century) since the Gregorian Calendar was instituted.( 1582 Oct 15)
It is just like a dictionary.

• Harshit Pathak

Hi,
its working perfectly for every other year but not with leap years…
for example 28-Aug-2004
(0+2+6+28-0) mod 7
36 mod 7
1 = Monday
but it was a Saturday
plz clear the concept of leap years

• Harshit Pathak

thanx anyway
i guess

• Sudhakaran Puthiyapurayil

from my book to find out the day of any date need not to do any calculation. it too easy than to find the meaning of a word from the dictionary. If you don’t believe , ask me any date and immediately a I

Thanking you, P.P Sudhakaran

• Dickson Junior

Quite a nice trick…I am my own calendar now..Im now a walking calendar.

• sudhakaran puthiya purayil

Mr. Sadasivsm, hi, u r not getting the correct answer of 5/12/2015? ok 2015 dec 1st was on Tuesday and 2nd Wed, 3rd Thu, 4th Fri and 5th Sat day. I am giving small calaendar for example 2015.

• sudhakaran puthiya purayil

And if u want know day of 5/12/ 2016 that is on Monday and 5 /12/ 2017 on Tues day, and 5/12/2035 is on Wed day. No need to do so many calculation. I prepared such a book” named calendar for ever” from which u can find out any day of date within seconds since the gregorian calendar was instituted.
U need not to do any calculation. it is more easy than to find out a word’s meanig from the dictionery.

• chandrasekhar

helo…sir
it is working correctly on other years…but not in leap year
for ex: 16 july 1776
(0+6+4+16) mod 7=26
26 mod 7=5
5 refers to friday..
but it was tuesday..
can u explain this..?

• Rahul Vashisth

Thanks!! Very usefull tricks and you save my lot of times….

• @chandrasekhar,

16 july 1776 was a Tuesday. Try doing the calculation again from the beginning.

(Year Code + Month Code + Century Code + Date Number – Leap Year Code) mod 7

(4 + 6 + 4 + 16 – 0) mod 7 =
30 mod 7 =
2 (Tuesday)

I think you have an incorrect result for the year code.

(YY + (YY div 4)) mod 7

(76 + (76 div 4)) mod 7 =
(76 + 19) mod 7 =
95 mod 7 =
4 (not zero)

• kishore kunal

Ho to calculate tha day on 7 nov 1786

• 7 nov 1786

You need to do this calculation:
(Year Code + Month Code + Century Code + Date Number – Leap Year Code) mod 7

Find the codes:

Year code: (YY + (YY div 4)) mod 7
(86 + (86 div 4)) mod 7
(86 + 21)) mod 7
96 mod 7
= 2

Month code: 3

Century code: 4

Leap Year: False (0)

Now put it together:
(Year Code + Month Code + Century Code + Date Number – Leap Year Code) mod 7

(2 + 3 + 4 + 7 – 0) mod 7

16 mod 7 = 2

2 means Tuesday

7 nov 1786 was a Tuesday

• Aruna

how to calculate for 6 march 2004?

• @Aruna: Please post the calculation that you have attempted, and we could take a look to see where there might be a mistake.

• Einstein’s birthday is 1879, not 1897 … thank you.

• Hi everyone,

I wanted to make a point for programmers who will use this nice formula to be careful with the Leap Year Code calculations. Subtracting 1 for the leap year could give you an unwanted negative value. This problem can be easily fixed by checking for a subtotal of 0 before subtracting the Leap Year Code. In this case you want your final answer to be 6 or Saturday. To illustrate my point look at what happens when you calculate for the week day February 27, 2016:

Start with ’16, leaving a Year Code of 6: YY = (16 + 16/4)%7 = 6
February has a Month Code of 3.
The Day Number is 27.
The Century Code for dates in the 2000s is 6.
2016 is a leap year, since it can be evenly divided by 4, and the date is in a January or February, so subtract 1 from the total in the final step.
Answer: ((6 + 3 + 27 + 6)%7 )– 1 = 0 – 1 = -1

• @gary: thanks for catching that. 🙂

I’ll update the post soon.

• Christian

There seems to be an error when trying to calculate the day from a leap year.
For example – Friday 14th October 2016
Year code: 16/4=4, 4+16=20, 20Mod7=6
Month code: 10
Century code: 6
Date Number: 14
Leap Year code: 1
Therefore – (6+10+6+14-1)=35, 35Mod7=0, 0=Sunday
However the day is Friday, not Sunday.

I’ve also tried numerous other leap year dates but have had no success. Please try and find a solution to the leap year errors.

• How would u calculate 6th April 2003.or a earlier date.

Thanks

• @mike @sharjeel: please post the exact steps showing your work, so I can see where you might be making a mistake. I’m happy to write out examples if people show their work.

@Christian: check the leap year rules again:

“If the date is in a January or February of a leap year, you have to subtract one from your total before the final step.”

So:
14 Oct 2016

(16 + (16 // 4)) % 7
(16 + 4) % 7
20 % 7
Year Code: 6

Month = 0
Century = 6
Leap year = 0 (not Jan or Feb)

(6 + 0 + 6 + 14 – 0) % 7

26 % 7 = 5
= Friday

• Hello josh

03 cant divide by 4 thats what i want to know.tell me first step please .
Thanks

• kindly tell i have two thing date 5 month september how find date

for january and feb. months we have to subtract 1 for leap years what about the remaining months. please give me the leap year codes which we have to subtract finally to get the formula

• Something seems off about certain dates I’ve calculated in the 1600s..

There’s a pattern though.
(If I count 4 days forward then it’s the right answer every time)
Assuming it has to do with the 11-day discrepancy for the Julian/Gregorian split. (??) Feel free to weigh in though!

Example – October-07, 1644
Month-Code: ——-0
Date-Number-“Code”: ——-7
Century-Code: ——-2
18-16=2
2 mod7 = 2
Year-Code: ——-6
(44 + 44/4) mod7
55 mod7
55-49= 6
Leap-Year-Code: ——-0
(Not Jan or Feb
Formula
(0 + 7 + 2 + 6 -0) mod7
15 mod7
15-14= 1
1=Monday
Result: Monday
Siri says Friday
Internet Says Friday

(4 days difference)
( Same for these dates also.. )
October-07, 1645
September-07, 1644
September-07, 1601
September-08, 1601

• shehab

i understand to subtract 1 if it’s a leap year and the month is jan or feb.. but when it ll be nov aug dec in a leap year then?????

• Subhojit

• Aman11012001

Clear more about Leap Year code…What about other months (march to december) ????

• Unnikrishnan

I have another idea to remember month code.

Fenomarch 3
Iacto zero
Apjuly6
dese5
aujune24
May day1

• Unnikrishnan K

EASY CALENDER BY U.K.K
Y= difference between 2018 and the target year + Number of Leap Years between them
M= Select monthcode: Jaocto zero ( Jan, Oct) , Fenomarch 3 ( Feb, Nov,March)
Decesep =5 ( December& Sept) Apjuly 6( April,July), May:1, Ag=2, June=4,
EQUATION is : (Date + M- Y) devide by 7
Note: if the reminder is negative add 7.
Take the reminder. 1=Mon 2=Tue 3= Wed 4= Thu 5= Fri 6=Sat, 0= Sunday.
Example:
15 August 1947
Take the deference from 2018=71
Add number of leap years between them = 18+71 =89
Month code for August is 2
Equation
15+2-89/7 and take reminder it is -2 and hence add seven=5 .. FRIDAY.

• UNNIKRISHNAN K

The above equation is for Year up to 2017.
After 2017 the equation is
(Date+M+Y) devided by 7

• venkatesh

(Easy method
Date+month code+century code+how many leap years complete in that year+year no )÷7

• 6th March, 2004 is coming wrong …plz reply
it was sunday but as per the method it is comming as saturday

• @prateek – please show all of your work, similar to how I did it in this comment (above). If you do that, then I can help walk through it.

• Biswajeet Tarai

I am very much pleased to know the day of particular date in this site. Thank you and all the viewers of this site for their clues. Once again thanks to all.

• Is any calculation for century code ? Likely month code also . There must be. Please explain it

• Please explain the calculation of century code

• @Josh Hi- Apparently, it’s not working for 24th March 2014.

Year code 2, Month code 3, Date 24, century code 6.

Remainder for 35/7 is 0. Hence, a Sunday. However, the correct answer is Monday. Please assist.

• Nevermind, got it. This method works. Thanks 🙂

• Can you show us the derivation of the codes and formulas used?

• Shubha

Can you please show us the working for 25 Dec 2025???
I’ve followed the steps as you have explained above yet I get the answer as 6 I.e Saturday. But the write answer is Thursday… So could you please explain this?

• @Shubha: could you write out all of the steps you performed in detail? Please read the comments above for an example. I’m happy to walk through examples if people show me their work first.

• Jyoti

Pl explain how to calculate the first step for year 2004. What to do if x mod 7 is a fraction?

• surendra

What is the day on 1-03 – 2008

• @Jyoti – you shouldn’t get a fraction. The “div” and “mod” refer to integer division (discard the remainder) and a modulo operation (keep only the remainder) respectively.

For 2004:

year code = (yy + (YY div 4)) mod 7

= (04 + (04 div 4)) mod 7
= (04 + (1)) mod 7
= 5 mod 7
= 5

So, if you’re trying to calculate August 29, 2004, you can do it like this:

The month code for August is 2.

The century code for the 2000s is 6.

The date number is 29.

2004 was a leap year, but we’re looking at August, so we don’t have to modify the output.

We can plug the numbers into the formula:

(Year Code + Month Code + Century Code + Date Number – Leap Year Code) mod 7

(5 + 2 + 6 + 29 – 0) mod 7

= 42 mod 7
= 0

August 29, 2004 was a Sunday.

• @surendra – please attempt it first and show your work in a comment. Then I can help with any errors. I’m happy to help, but I would like to see an attempt first. 🙂

• Naresh

Please tell me which centuries consider in Julian and in gregorian calendar. Thank you

• What was the day of week on 19th June 1440

• @Naresh – the answer is in the article above under the heading “The Century Code”.

@sohan – please try it yourself at least once, and post your steps here. Then I can help solve it. 🙂

Hello i am a Programmer I loved this technique. I made a java program which does all the job like a charm please suggest me more similar techniques which i can convert into programs

• SENTHIL KUMAR

I am not sure If am doing any mistake for the date – 14/2/1723.
Year Code = 7
Month Code = 3
Century Code = 4
Date = 14
Day should be Sunday. But the correct answer is Thursday.

• I am not getting ans for 15/5/2004

• @Senthil – did you take into account Julian Dates? Double-check that section of the post above.

@Sai – please write out the steps that you tried and then I will be able to see where you might have made a mistake in the calculation.

• nishant

For 23 Oct 1978 I am getting sunday, where as the day on that date is Monday. My formula is (23+0+0+2-1) mod 7 (day+month+century+year-leap)mod7. Correct me If I am wrong.

• nishant

(23+0+0+6-1)mode 7

• @nishant 1978 isn’t a leap year, so you don’t need to subtract 1 there. (1978/4 = 494.5)

(year + month + century + date – leap) mod 7
(6 + 0 + 0 + 23 + 0) mod 7 = 1 = Monday

• @Kirk
You did a mistake. You have to subtract 1 after adding all values not after mod 7

• And thankyou Josh Cohen for amazing method to find day. It is very helpful in olympiads

• Amanpreet Singh

Thanx for posting such a smart method. But how can we get Century codes for :

Gregorian– before 17th century and after 23th century.
Julian- after 18th century.

Regards

• Ankush

My date of birth is 28 feb, 2002. When i am appling Year code i.e ( YY +(YY div 4)mod 7, i am getting this number (02+(0.2)mod 7. Here i am getting number in point then how to solve it

• Naresh Kumar sharma

Hello,
DOB 28/12/1976
Year code
76/4=19
76+19=95
95mod7=4
Year code=4
Month code
Dec=5
Date code=28
Century code=0
Leap year=1
(4+5+28+0-1=36
36mod7=1
1=moday
But birthday is Tuesday

• That was such a good leap. But I am not getting the correct day for 3rd of April 1993.
93 div 4 = 24
93 +24 = 117 mod 7 = 5 = year code
century code for 1900 = 0
month code for April = 6
not a leap year, hence leap year code = 0

(5+6 +3)mod 7 = 14 mod 7 = 0 which suggests Sunday while Saturday is the correct day.
Any way out? Thnaks

• Pelle Chamliden

Hello!
A tip : 7 mod 7 = 0.

Means that you can reduce your calculations on the go, once you have gotten a hang on how to perform the basics.

Ex, Dec 28th 1974 :
Year code : ((74 div 4) + 74) mod 7 = ( 4 + 4 ) mod 7 = 1
Day code 28 mod 7 = 0
Month code : 5
Century code : 0

Adding : 1+0+5+0 = 6 –> Saturday

In conclusion, you can reduce away multiples of 7 during the calculations except from the YY div 4 there YY needs to be intact,but its result can be reduced.

When doing this on time constraints ,you start with the year code div part and reduce it (if needed) , reduce the YY and add, reduce that and add next part… This to reduce the need have “mnemonic carry” in your calculations.

As someone mentioned another algorithm using the month code list for 2018 ( 033614625035 ) , this is the same used in here for general calculation(s) for Julian and gregorian calendars.

4206420 , can also be reduced to just 4206 , it is just cycling those values.

You can memorize it as a compass, counting centuries clockwise from North – code 4 (1700s). East – code 2 (1800s,). South –
code 0 (1900s). West – code 6 ( 2000s ).
North – code 4 ( 2100s ). East – code 2 ( 2200s ) and so forth…

• xcroud

Hey Josh, just want to ask.

What’s the logic behind the leap code? Why January and February for the leap_code to reach 1, specifically?

• sam nil

wrong method……………….14 oct 1066 is sunday not saturday

• D. Crandall

Here’s the method I worked out for Gregorian Dates:
– If the month is before March, subtract 1 from the year.
1500s: 17 1900s: 17 2300s: 17
1600s: 16 2000s: 16 2400s: 16
1700s: 14 2100s: 14 2500s: 14
1800s: 19 2200s: 19 2600s: 19
(The numbers 19, 17, 16 and 14 repeat every four centuries, with the centuries evenly divisible by 400 being 16.)
Add to it the last two digits of the year.
Add one fourth of the last two digits of the year, ignoring fractions or remainders.
Add the day of the month.
If the month is in this simple list below, add the code below it:
Jan Feb Mar May Jul Sep Nov
6 3 3 3 3 4 4
(The only even-numbered month in this list is February, the second month, as the other even month codes would all be zero, so you don’t need to add a code for them!)
Subtract the number of the month:
Jan Feb Mar Apr etc.
1 2 3 4
Now divide the number by seven, and the remainder will tell you the day of the week, with zero being Sunday, one being Monday, two being Tuesday, three being Wednesday, four being Thursday, etc.
Example: July 4, 1776 (7-4-1776):
14+76+19+4+3-7=109
109/7=15, remainder 4=Thursday.

• Bapi pal

Good thing but i want to formula of colck hour angle

• @Bapi pal – something like this?
https://en.wikipedia.org/wiki/Clock_angle_problem

• @sam nil – I’m pretty sure that the Battle of Hastings was on a Saturday. Verify here:
http://www.wolframalpha.com/input/?i=14+October+1066+julian

• Akila

Hi,

could you explain the logic behind the formula and calculation. I dont want just memorize it without understanding.

• Suvarna

27-February-2008 is Wednesday but how can we get .
Can anyone explain it in detail.

• Robin

Previously these calender questions used to trouble me most …….. but not anymore…. 🙂

• Khaled Bizri

The algorithm provided works perfectly. It was used to run across many years, leap and otherwise and it rendered the correct values for the day.

The programming algorithm is provided below:

int yearCount = year – ((year / 100) * 100);
int yearCode = ((yearCount/4) + yearCount) % 7;

int monthCode = monthCodes[month – 1];
int centIndex = ((year – yearCount) – centList[0]) / 100;
int centCode = centCodes[centIndex];

int leapYearCode = getLeapYearCode(year, month);
int total = centCode + yearCode + monthCode + day – leapYearCode;
int dayNo = total % 7;

References to monthCodes[] and centCode[] are satisfied by the arrays:

int[] monthCodes = {0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5};
int[] centCodes = {4, 2, 0, 6, 4, 2, 0};

Excellent!

• Atanu

@ Josh: I think the Century code come by this formula

Century offset calculation (Gregorian Calendar):

Step1 :Take the first two digit of the given year.

Step2 :Calculate the next highest multiple of 4 for the first two digit number.

Step3 :Subtract 1 from the number.

Step4 :Then, subtract the first two digit from the number.

Step5 :Finally, multiply the resultant value with 2.

Example:
Calculate century offset for 1900s century.

Let us take the first two digit 19.

The next highest multiple of 4 for the first two digit number 19 is 20.

Subtract 1 from the number. i.e. 20-1

Subtract the first two digit of the given number i.e ((20-1)-19)

Finally, multiply the resultant value with 2..

1900s = ((20-1)-19)*2 = 0.

Below given Gregorian Century Offsets table shows the other century and offset values,

Century Offset
300, 700, 1100, 1500,1900, etc. 0
400, 800, 1200, 1600, 2000, etc. 6
100, 500, 900, 1300, 1700, etc. 4
200, 600, 1000, 1400, 1800, etc. 2

• Atanu

@ Josh: Calculation for Month code will be like this
Find the Month Offset:

Consider there are 4 weeks in a month, which means 4 x 7 = 28 days. January has 31 days. The days remaining are 31-28=3. The reminder helps you in calculating the numbers for each month.

Initially, Take Jan as 0

February = ( Number of days in Jan + Remaining days in Jan ) / 7) = (31+0)/7 = 3

March = ( Number of days in Feb + Remaining days in Feb ) / 7) = (28+3)/7 = 3

April = ( Number of days in Mar + Remaining days in Mar ) / 7) = (31+3)/7 = 6

Continue the same process till December… The numbers for the months are,

Month Offsets table:
Month Offset
January 0
February 3
March 3
April 6
May 1
June 4
July 6
August 2
September 5
October 0
November 3
December 5

• Pirabakaran.R

What is the main difference in Gregorian and Julian calendar dates and days.

• Cypher

What to do to calculate for Dates 2500

• Afsal

Brother, if it is not jan or feb of leap year what number i substract from the formula?

• Devesh Chaudhary

1 Jan 2000 को कैलकुलेट करने में ही दिक्कत हो रही थी। थैंक्स

Its not real method to know

• I did 27th June 270bce. I did 6 4 2 0 all the way up to 0, which was the day Jesus was born, and then I went on until the year 270bce. Then I did 18-2=16 mod 7 which was 2. Then I did 4 (June’s month code is 4) + 4 (when I did 6,4,2,0 all the way up to 270bce) + 27 (date) + 2 (the Julian year code) =37. The closest I could get was 7*5=35. The remainder was 2. 2 is Tuesday. I looked on the computer and it said a Monday. Why didn’t it work?

• Paul Berg

29-11-1945
I get a wrong answer here.

• Paul Berg

I meant 29-11-1645

• hello sir
it is working correctly on other years…but not in leap year
19 april 2000
year code 0
month code 6
century code 6
day number 19
leap year 1

(year code+month code+century code+day number-leapyear)mob7
(0+6+6+19-1)/7
(31-1)/7
30/7
2
2- tuesday
but this day is wednesday

• Mukesh Kumar

Anyone can ask me correct day of and date of any year thousands year back or croro years ago.
One lakh rupees will be given if my answer is wrong.

• Mukesh Kumar

These formula are not correct. i have right formula. anybody can ask me right answer.

• Thank you sir. But I am not able get the answer in case of leap year..plz explain it in a simple way..

• roshan singh

It is not working for leap year….27/08/1996

• soumanmanda: this is ur mistake….for leap year its true, that u minus 1 in the end from the total…
but when the year is leap year as well as century?? then the odd day for that year is 0!! therefore 19 april 2000 comes on wednesday!!!

• Nithin Sagar

Good I like it very much

This site uses Akismet to reduce spam. Learn how your comment data is processed.