Xref: utzoo comp.sys.ibm.pc:11135 sci.math:2737 Path: utzoo!mnetor!uunet!husc6!mit-eddie!uw-beaver!uw-june!uw-entropy!dataio!suvax1!spector From: spector@suvax1.UUCP (Mitchell Spector) Newsgroups: comp.sys.ibm.pc,sci.math Subject: Re: Calendar calculations Message-ID: <936@suvax1.UUCP> Date: 24 Jan 88 21:15:53 GMT References: <485@psu-cs.UUCP> Organization: Seattle University, Seattle, WA. Lines: 28 Summary: A formula for the day of the week from the date In article <485@psu-cs.UUCP>, winterss@psu-cs.UUCP (Stafford Winters ) writes: > I would like to know the formula for calculating the day of the week for any > given date. I have seen it once before, but I didn't write it down. Having > > Tad Winters Here's a formula given in the book An Introduction to the Theory of Numbers, by Niven and Zuckerman. Let M be the number of the month, defined so that Jan = 11, Feb = 12, Mar = 1, Apr = 2, ..., Dec = 10. Let N be the number of the day within the month. Let C be the hundreds in the year, and let Y be the rest of the year. Let L be 1 for a leap year and 0 for a non-leap year. The formula (N + [2.6M - 0.2] + Y + [Y / 4] + [C / 4] - 2C - (1 + L)[M / 11]) mod 7 yields 0 for Sunday, 1 for Monday, ..., 6 for Saturday. (Square brackets denote the greatest integer function.) -- Mitchell Spector |"Give me a Dept. of Computer Science & Software Eng., Seattle Univ.| ticket to Path: ...!uw-beaver!uw-entropy!dataio!suvax1!spector | Mars!!" or: dataio!suvax1!spector@entropy.ms.washington.edu | -- Zippy the Pinhead