Day Of Week function 
Author Message
 Day Of Week function

Although this may sound like some elementary project, I was wondering if anybody
knows/remembers a function to figure out the day of week given the month, date
and year.



Wed, 18 Jun 1902 08:00:00 GMT  
 Day Of Week function

Quote:

> Although this may sound like some elementary project, I was wondering if anybody
> knows/remembers a function to figure out the day of week given the month, date
> and year.

Based on a recent newsgroup posting, I wrote this function.  Not extensively tested
but I tried a few values and it seems to work.  The original poster described this
as Zeller's algorithm.

  function zeller(day, month, year : integer) : integer;
    { Returns the day of the week, 0 = Sunday, 1 = Monday, ..., 6 = Saturday.
      day   - day of the month, 1 to 31.
      month - month of the year, 1 to 12.
      year  - a four digit integer, ie 1996.  }

    begin
      month := month - 2;
      if month <= 0 then
        begin
          month := month + 12;
          year := year - 1;
        end;
      zeller := ( day + (13 * month - 1) div 5 + 5 * (year mod 100) div 4
                - 7 * year div 400) mod 7;
    end;  { of function zeller }

Good luck.
Bob.



Wed, 18 Jun 1902 08:00:00 GMT  
 Day Of Week function


:Although this may sound like some elementary project, I was wondering if anybody
:knows/remembers a function to figure out the day of week given the month, date
:and year.

Covered in

3) What is the code for the weekday of a given date?

 99848 May 19 1996 ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip
 tsfaqp.zip Common Turbo Pascal Questions and Timo's answers

   All the best, Timo

....................................................................

Moderating at ftp:// & http://garbo.uwasa.fi archives  193.166.120.5
Department of Accounting and Business Finance  ; University of Vaasa



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Procedure to calculate Day of Week

2. WANTED: Procedure to calculate Day of Week

3. Day in week and week in year calculations, oops!

4. Week function needed

5. Weeks of searching - Turbo Access?

6. GUARANTEED 2-5 LBS WEIGHT LOSS PER WEEK

7. Week Number

8. Program for Week number

9. Learning Pascal in 8 weeks-help!

10. 500,- per week bijverdienen als programmeur

11. Date to Week Number

12. GUARANTEED 2-5 LBS WEIGHT LOSS PER WEEK

 

 
Powered by phpBB® Forum Software