Zeller's congruence is an algorithm devised by Christian Zeller in the 19th century 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. Formula For the Gregorian calendar, Zeller's congruence is for the Julian calendar it is where 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 (). J is the zero-based century (actually ) For example, the zero-based centuries for 1995 and 2000 are 19 and 20 respectively (not to be confused with the common ordinal century enumeration which indicates 20th for both cases). is the floor function or integer part mod is the modulo operation or remainder after division 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 Analysis These formulas are based on the observation that the day of the week progresses in a predictable manner based upon each subpart of that date. Each term within the formula is used to calculate the offset needed to obtain the correct day of the week. For the Gregorian calendar, the various parts of this formula can therefore be understood as follows: represents the progression of the day of the week based on the day of the month, since each successive day results in an additional offset of 1 in the day of the week. represents the progression of the day of the week based on the year. Assuming that each year is 365 days long, the same date on each succeeding year will be offset by a value of . Since there are 366 days in each leap year, this needs to be accounted for by adding another day to the day of the week offset value. This is accomplished by adding to the offset. This term is calculated as an integer result. Any remainder is discarded. Using