Zeller’s congruence is an algorithm devised by Christian Zeller to calculate the day of the week for any Julian or Gregorian calendar date. It can be considered to be based on the conversion between Julian day and the calendar date.
It is an algorithm to find the day of the week for any date.
For the Gregorian calender it is:
For the julian calender it is:
- h is the day of the week (0 = Saturday, 1 = Sunday, 2 = Monday, …, 6 = Friday)
- q is the day of the month
- m is the month (3 = March, 4 = April, 5 = May, …, 14 = February)
- K the year of the century ( year % 100).
- J is the zero-based century (actually ⌊ year/100 ⌋ ) For example, the zero-based centuries for 1995 and 2000 are 19 and 20 respectively (to not be confused with the common ordinal century enumeration which indicates 20th for both cases).
NOTE: In this algorithm January and February are counted as months 13 and 14 of the previous year.E.g. if it is 2 February 2010, the algorithm counts the date as the second day of the fourteenth month of 2009 (02/14/2009 in DD/MM/YYYY format)
For an ISO week date Day-of-Week d (1 = Monday to 7 = Sunday), use
d = ((h+5)%7) + 1
This article is contributed by Amartya Ranjan Saikia. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Find the day of the week after K days from the given day
- Linear Congruence method for generating Pseudo Random Numbers
- Multiplicative Congruence method for generating Pseudo Random Numbers
- Additive Congruence method for generating Pseudo Random Numbers
- Find day of the week for a given date
- Python program to find day of the week for a given date
- Find the day number in the current year for the given date
- C++ Program to print current Day, Date and Time
- How to get Day, Month and Year from Date in Java
- Date after adding given number of days to the given date
- Find the number of times every day occurs in a month
- Program to find the time remaining for the day to complete
- Tomohiko Sakamoto's Algorithm- Finding the day of the week
- Probability of rain on N+1th day
- Print day of week using Gregorian Calendar in java
- Problems not solved at the end of Nth day
- Count of days remaining for the next day with higher temperature
- Queries to find the future closest date
- Time Functions in Python | Set-2 (Date Manipulations)
- Date class in Java (With Examples)
Improved By : jit_t