Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

What day of week is this???

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • What day of week is this???

    It is absolutely amazing how many times this situationoccurs in DP. Next to the DOLLAR SIGN, dates are the most important datum in any business function. If you have ROBOT it has a day of week function. If youcan find it, there is an API for it, but I have never looked... The one I use is in the 1934 edition of Websters New collegiate Dictionary ;; by the way it works through2299 and is under perpetual calendar; It goes as follows: 1. take the last two figures of the year (e.g. 97) and add the integer(yy/7) (no decimal fraction); 2. for the current century add 0; for the next century, add 6.3 for the months add: 0 for april or july; 1 for jan or oct; 2 for May; 3 for aug; 4 for feb mar or nov; 5 for june; 6 for sept or dec; if a leap year use instead 0 for jan & 3 for feb.4. add the day of month;5 divide the result by 7 and the remainder will represent the DOW: with 0 = sat; 1 = sun etc. I have programmed this algorithm in assembler, algol, cobol and RPG and I know of a version in Auto-coder, C and PASCAL. Incidently ;; january 1st, 2000 will be Saturday; check it out.this means monday jan 3rd , 2000 will be a holiday so we will nothave to worry about 2 digit year stuff until tuesday! bob hamilton, texas business systems; 736 pinehurst; richardson, texphone 817-898-6770 off; 972-705-9214 home... No One Ever Needed a Smaller, Slower PC

  • #2
    What day of week is this???

    Hi Kendall, Date-handling capabilities are not limited to V3R2 but to RPG/IV. - so if you have the ILE RPG compiler, calculating the duration between two dates and in terms the day of week is straight forward. About the OPNQRYF-approach; I noticed that Ted Holt published the technique in Tech Talk January 1996. Please let me know if you need further information (I've got an RPG/400-inline (6/8-digits date) that works very well too). Best regards, Carsten

    Comment


    • #3
      What day of week is this???

      Hi Kendall, Date-handling capabilities are not limited to V3R2 but to RPG/IV. - so if you have the ILE RPG compiler, calculating the duration between two dates and in terms the day of week is straight forward. About the OPNQRYF-approach; I noticed that Ted Holt published the technique in MC Tech Talk January 1996. Please let me know if you need further information (I've got an RPG/400-inline (6/8-digits date) that works very well too). Best regards, Carsten

      Comment


      • #4
        What day of week is this???

        Bob: I tried to get the day of the week using your formula for March 26, 1997 which is Wednesday. 97/7 = 13 without decimals. 97 + 13 + 0 + 4(march) + 26 = 140 140 mod 7 = 0 = Saturday. Did I miss something ? Regards, HREF="http://www2.cybernex.net/~irash/">Ira On Sunday, March 23, 1997, 09:19 AM, bob hamilton wrote: 1. take the last two figures of the year (e.g. 97) and add the integer(yy/7) (no decimal fraction); 2. for the current century add 0; for the next century, add 6. 3 for the months add: 0 for april or july; 1 for jan or oct; 2 for May; 3 for aug; 4 for feb mar or nov; 5 for june; 6 for sept or dec; if a leap year use instead 0 for jan & 3 for feb. 4. add the day of month; 5 divide the result by 7 and the remainder will represent the DOW: with 0 = sat; 1 = sun etc.

        Comment


        • #5
          What day of week is this???

          the DOW formula is in ALGOL for ccYYMMDD case( MOD( YY + mod(YY, 4) + ( case cc = 19 then 0; cc = 20 then 1 + mm + dd ) ,7 ) = 0 then "Saturday"; OR = 1 then "Sunday"; et c ) . the case statement give s the correction for century nbr. i dont haveat hand the nbr for 17th and 18th centruy, but 19 is 0) No One Ever Needed a Smaller, Slower PC

          Comment


          • #6
            What day of week is this???

            I don't get Bob's formula either Today is Thursday Nov 6 1997. 97/7 = 13 97+13=110 110+0=110 (for current century) . 110+4=114 (for november) . 114+6=120 (for day in month) . 120/7 = 17 rem 1. 1=SUN, not Thursday.... Bob?.Chris Ringer....

            Comment


            • #7
              What day of week is this???

              Bob E-mailed me and explained that in the first step, you should divide by 4 not 7. Thanks Bob. Chris Ringer...

              Comment


              • #8
                What day of week is this???

                On Tuesday, November 25, 1997, 12:24 PM, Chris Ringer wrote: Bob E-mailed me and explained that in the first step, you should divide by 4 not 7. Thanks Bob. Chris Ringer...
                from the formula can you tell why this year's calendar is identical to that for 1941??? Bob Hamilton TEXAS BUSINESS SYSTEMS 736 Pinehurst Richardson, Texas 75080

                Comment

                Working...
                X