Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!samsung!uakari.primate.wisc.edu!dali!milton!uw-beaver!fluke!db From: db@tc.fluke.COM (Dan Banay) Newsgroups: comp.lang.pascal Subject: Day of the week Keywords: date Zeller Message-ID: <1990Apr12.155243.12303@tc.fluke.COM> Date: 12 Apr 90 15:52:43 GMT Distribution: usa Organization: John Fluke Mfg. Co., Inc., Everett, WA Lines: 36 The following function will return the day of the week for a given date: (* e.g. m = 8 d = 10 y = 1988 *) (* returns 0 = Sunday... *) (* uses Zeller's Algorithm *) function dayw(m,d,y:integer):integer; var century:integer; begin if (m > 2) then m := m -2 else begin m := m + 10; y := y - 1 end; century := y div 100; y := y mod 100; dayw := (d-1+((13*m-1) div 5)+(5*y div 4)+(century div 4)-2*century+1) mod 7; end; Examples: x := dayw(8,10,1988); (* 3 Wed *) y := dayw(2,29,1992); (* 6 Sat *) I can't remeber where I found the algorithm (from a magazine or book) since I'm getting old and senile. ;-) If anyone has additional information about Zeller's algorithm, I'd be interested in hearing about it. Hope this helps, Dan