Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

Day of the week

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

  • Day of the week

    This has been hammered ad nauseum; search for DOWK or Day of Week. Any worthwhile computer language has had this function for twenty + years. imnsho bobh

  • #2
    Day of the week

    Trevor, If you think about it, day of the week is pretty simple. Find the day of the week for a given date in the past (call this the base date). Convert the date you want to examine to the number of days. Subtract 1 from this value and then divide by seven. The remainder is the day of the week offset from the base date. Leap years and other calendar oddities don't apply because Monday always follows Sunday. Bill > Does anyone know of a way to determine what day of the week a certain date falls on? (I should say without writing a complex program that will determine if it's a leap year and all that stuff and then give you the day of the week) I think you can do it in C, but I don't know how. Does anyone have any thoughts? Thanks!

    Comment


    • #3
      Day of the week

      I agree Bob, but the message has not gotten through to everyone. Part of the problem is the lack of documentation for routines provided by IBM. Oh, I know the documentation exists, but unless you are aware of it, you will not know where to look. The poster of a question of this nature would not know to look up the CEExxxx routines unless someone tells them. IBM has done a very good job of keeping this functionality hidden. I would tell the poster that in addition to IBM's CEExxxx date routines, that code exists on this web site which will solve the problem. Dave

      Comment


      • #4
        Day of the week

        If I am reading your short hand correctly, I would have to agree with the last statement 100%.

        Comment


        • #5
          Day of the week

          Bill the traditional start - base - date was 31 Dec 1899 , a sunday. Many older programs assumed 1900 was a leap year and this threw the thing off after 28 Feb 1900. Both Excel and 1-2-3 from which it was stolen had this error. bobh

          Comment


          • #6
            Day of the week

            The nice part about the CEExxxx routines, is that you don't care about a base date. Just call the routine that converts the date to lillian format, and then call the routine that returns a day of the week from the lillian format. I am aware that the lillian format date has a base, but my programming does not have to care about it. Dave

            Comment


            • #7
              Day of the week

              here's what i did when i had to validate that the enddate must be a Saturday . . . D BaseDate S D Inz(D'1582-10-14') D NDays S 10I 0 D nDayOfWeek S 10I 0 D IsoDte S D DatFmt(*iso) C *usa Move EndDate IsoDte C IsoDte Subdur BaseDate nDays:*D C CallB 'CEEDYWK' C Parm nDays C Parm nDayOfWeek C if nDayOfWeek is 1 = Sunday 2 = Monday 3 = Tuesday 4 = Wednesday 5 = Thursday 6 = Friday 7 = Saturday Maria D.

              Comment


              • #8
                Day of the week

                Here's another approach, yielding 1=Sunday, ... 7=Saturday, for today's date:

                D OneSunday s d Inz(d'1776-07-07') D Now s d Inz(*SYS) D DayNo s 10i 0 C Now Subdur OneSunday DayNo:*D C Eval DayNo = 1 + %Rem(DayNo : 7)

                Comment


                • #9
                  Day of the week

                  I've got a program that displays journal entries that have been archived to a membered file. The member display can be sorted by date or by journal name. Upon selection of the journal to look at it can be sorted by date, account #, location, or amount. Where I have run into a snag is with the amount. I use a dataQ to sort the subfile and determine the key by cursor location. I use the %char() bif to move the date or amount into the key. Then load the queue and read it back to the subfile in key sequence. The amounts get left justified with no leading zeros, this causes the sort to get real funny looking. I know I can do a straight MOVE, but the program is in free form and I would like to keep it completely free. I know I am being stubborn, but this is an excercise and I'd like to find a way to do this. TIA Bill

                  Comment


                  • #10
                    Day of the week

                    Posted message in wrong place. My apologies.

                    Comment


                    • #11
                      Day of the week

                      Does anyone know of a way to determine what day of the week a certain date falls on? (I should say without writing a complex program that will determine if it's a leap year and all that stuff and then give you the day of the week) I think you can do it in C, but I don't know how. Does anyone have any thoughts? Thanks!

                      Comment


                      • #12
                        Day of the week

                        Help I have a question for any subfile gurus out there. I have a subfile program, the first field which is input/output capable where the user enters a D or C. If the user keys anything but a C or a D, I want to position the cursor on that field and highlight the entry. A READC works with the SFLNXTCHG keyword works, but if I correct the wrong entry and key a bad entry for line 2, both lines are highlighted. I want to disable the first record highlighting and postion the cursor on the second line. How is this accomplished... Thanks Mike

                        Comment


                        • #13
                          Day of the week

                          Mike, You could take the easy way and just code this logic at the DDS level. The keyword to use is VALUES. Be aware though, that the validation happens whether or not the user were to hit F12 or F3 to try to get out of the screen. Bill > I have a question for any subfile gurus out there. I have a subfile program, the first field which is input/output capable where the user enters a D or C. If the user keys anything but a C or a D, I want to position the cursor on that field and highlight the entry.

                          Comment

                          Working...
                          X