VOOZH about

URL: https://www.geeksforgeeks.org/maths/tricks-to-solve-calendar-problems/

⇱ Tricks to Solve Calendar Problems - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Tricks to Solve Calendar Problems

Last Updated : 23 Jul, 2025

The topic of calendars is essential for various competitive exams and placement tests. While it might initially seem challenging, the tricks and methods shared here will simplify the concepts, making calendars easy to understand and apply.

A calendar is a system for organizing and dividing time into days, weeks, months, and years. Calendars are based on astronomical events, such as the rotation of the Earth (day), the lunar cycle (month), and the Earth's orbit around the sun (year), and have been essential for managing time and planning in societies throughout history.

Basic Concepts and Terminology

Leap Year:

  • A year with 366 days, in which February has 29 days.
  • A year is a leap year if it is divisible by 4. However, if it’s a century year (ending in 00), it must be divisible by 400 to be a leap year.
  • For example, 2000 was a leap year, but 1900 was not.

Ordinary Year

  • A year with 365 days, in which February has 28 days.
  • Non-leap years are not divisible by 4 or do not satisfy the century rule (not divisible by 400).

Odd Days

  • The number of days left after calculating complete weeks in a given period.
  • Odd days help in determining the day of the week for a given date.
  • For example, if 10 days pass, it’s 1 complete week (7 days) and 3 odd days.

Day Codes

Days of the week can be assigned numerical codes to simplify calculations:

Sunday

Monday

Tuesday

Wednesday

Thursday

Friday

Saturday

0

1

2

3

4

5

6

Month Codes

Each month is given a code to simplify day calculations, particularly for non-leap and leap years:

Month

Code

January

For leap year: 6, For non-leap year: 0

February

For leap: 2, For non-leap year: 3

March

3

April

6

May

1

June

4

July

6

August

2

September

5

October

0

November

3

December

5

Century Codes

The century codes are used to simplify day-of-week calculations for dates across centuries.

Century

Code

1600-1699

6

1700-1799

4

1800-1899

2

1900-1999

0

2000>=

6

Types of Questions

Type 1: Given a month, date, and year, use this data to find the day of the week.

Type 2: Given a day, with its date, find which day will be after x months, x days, or x years.

Tricks and Shortcuts for Calendar Questions

Let us Understand them with the help of small and easy tricks.

The Date-to-Day Code Trick

Suppose we have given a date like 25 May 2003. and we have to calculate the day for this.

Trick
Step: 1 = last 2 digits of a year
Step: 2 = month code
Step: 3 = Date
Step: 4 = last 2 digits of year divided by 4(quotient)
Step: 5 = Year code
Now add all these and find its remainder with 7.
Now, whatever the value you are getting convert it into Week Day Code and We will get the required Day.

Solving the above example:

  • Step: 1 The last 2 digits of a year is 03 i.e 3.
  • Step: 2 month code for May is 1.
  • Step: 3 Date is 25.
  • Step: 4 The last 2 digits divided by 4 is  0 i.e  3/4 gives quotient as 0.
  • Step: 5 Year code is 6.

Adding them ( values obtained after all the 5 steps )

We get  (3 +1 + 25 + 0 + 6) = 35.

So, 35/7 = 0(Remainder).

And we have already mentioned in Trick’s section that  0 is the Code for Sunday. So, the Weekday on 25 May 2003 was Sunday.

Day Difference Trick

It was Monday 15th October 1923. What was the day on 17 November 1923?

TRICK - We simply have to add the day's between two given dates, and add it to the code of the day given
in question and divide it by 7 to get the remainder .

Solving the above question:

Since October has 31 days, there are 16 days from October 15 to October 31, and 17 days from November 1 to November 17.

Adding these gives (16 + 17) = 33 days.

Dividing 33 by 7, we get a remainder of 5.

Now, add 5 to the code for Monday (1, as given in the tricks), then divide by 7 to find the remainder: (5 + 1) mod  7 = 6. This remainder of 6 corresponds to Saturday.

Hence, it was Saturday on 17th November 1923.

Zeller Congruence

Zeller’s congruence is an algorithm devised by Christian Zeller to calculate the day of the week.

It is given by the formula:

Where

  • f is the day of the week.
  • d is the day of the month.
  • m is the month (March = 3, April = 4, ..., December = 12; January = 13, February = 14 of the previous year).
  • Y is the year mod 100.
  • C is the year / 100.

In the traditional Zeller's congruence algorithm, the resulting value, f, is mapped as follows:

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

For example: 20th March 1882

Solution:

For the given question the solution through Zeller's formula is :

  • f is to be calculated
  • d = 20
  • m = 3
  • Y = 82
  • C = 18.82 = 18 (we will take 18 as we have to choose the floor value).

= (20 + 10 +82 + 20 +4 -36) mod 7

(100) mod 7

= 2 (According to the code for the week).

Hence it was Monday on 20th march 1882.

The Ordinary Year Month Code Trick

In an ordinary year, the first days of the month are the same for:

  • January and October (1-10)
  • April and July (4-7)
  • February, March, and November (2-3-11)
  • September and December (9-12)

The Leap Year Month Code Trick

In a leap year, the first days of the months are the same for:

  • January, April, and July (1-4-7)
  • February and August (2-8)
  • March and November (3-11)
  • September and December (9-12)

Also Check:

Comment

Explore