VOOZH about

URL: https://www.geeksforgeeks.org/dsa/zellers-congruence-find-day-date/

⇱ Zeller's Congruence | Find the Day for a Date - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Zeller's Congruence | Find the Day for a Date

Last Updated : 18 Jan, 2024

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's day and the calendar date. 
It is an algorithm to find the day of the week for any date. 
For the Gregorian calendar it is:

For the Julian calendar it is: 

where, 

  1. h is the day of the week (0 = Saturday, 1 = Sunday, 2 = Monday, ..., 6 = Friday)
  2. q is the day of the month
  3. m is the month (3 = March, 4 = April, 5 = May, ..., 14 = February)
  4. K is the year of the century (year % 100).
  5. 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 

Output
Sunday 

Time Complexity: O(1)
Auxiliary Space: O(1)


Another variation of Zeller's Congruence formula:


Output
Friday


Comment
Article Tags: