Rational Developer for System z
COBOL for Windows, Version 7.5, Programming Guide


CEEDYWK—calculate day of week from Lilian date

CEEDYWK calculates the day of the week on which a Lilian date falls as a number between 1 and 7.

The number returned by CEEDYWK is useful for end-of-week calculations.

CALL CEEDYWK syntax
Read syntax diagramSkip visual syntax diagram>>-CALL--"CEEDYWK"--USING--input_Lilian_date,--output_day_no,--->
 
>--fc.---------------------------------------------------------><
 
input_Lilian_date (input)
A 32-bit binary integer that represents the Lilian date, the number of days since 14 October 1582.

For example, 16 May 1988 is day number 148138. The valid range of input_Lilian_date is between 1 and 3,074,324 (15 October 1582 and 31 December 9999).

output_day_no (output)
A 32-bit binary integer that represents input_Lilian_date's day-of-week: 1 equals Sunday, 2 equals Monday, . . ., 7 equals Saturday.

If input_Lilian_date is invalid, output_day_no is set to 0 and CEEDYWK terminates with a non-CEE000 symbolic feedback code.

fc (output)
A 12-byte feedback code (optional) that indicates the result of this service.

Table 88. CEEDYWK symbolic conditions
Symbolic feedback code Severity Message number Message text
CEE000 0 The service completed successfully.
CEE2EG 3 2512 The Lilian date value passed in a call to CEEDATE or CEEDYWK was not within the supported range.

Example

CBL LIB
      ************************************************
      **                                            **
      ** Function: Call CEEDYWK to calculate the    **
      **           day of the week from Lilian date **
      **                                            **
      ** In this example, a call is made to CEEDYWK **
      ** to return the day of the week on which a   **
      ** Lilian date falls. (A Lilian date is the   **
      ** number of days since 14 October 1582)      **
      **                                            **
      ************************************************
       IDENTIFICATION DIVISION.
       PROGRAM-ID. CBLDYWK.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  LILIAN                  PIC S9(9) BINARY.
       01  DAYNUM                  PIC S9(9) BINARY.
       01  IN-DATE.
           02  Vstring-length      PIC S9(4) BINARY.
           02  Vstring-text.
               03  Vstring-char        PIC X,
                           OCCURS 0 TO 256 TIMES
                           DEPENDING ON Vstring-length
                               of IN-DATE.
       01  PICSTR.
           02  Vstring-length      PIC S9(4) BINARY.
           02  Vstring-text.
               03  Vstring-char        PIC X,
                           OCCURS 0 TO 256 TIMES
                           DEPENDING ON Vstring-length
                               of PICSTR.
       01  FC.
           02  Condition-Token-Value.
           COPY  CEEIGZCT.
               03  Case-1-Condition-ID.
                   04  Severity    PIC S9(4) COMP.
                   04  Msg-No      PIC S9(4) COMP.
               03  Case-2-Condition-ID
                         REDEFINES Case-1-Condition-ID.
                   04  Class-Code  PIC S9(4) COMP.
                   04  Cause-Code  PIC S9(4) COMP.
               03  Case-Sev-Ctl    PIC X.
               03  Facility-ID     PIC XXX.
           02  I-S-Info            PIC S9(9) COMP.

       PROCEDURE DIVISION.
       PARA-CBLDAYS.
      ** Call CEEDAYS to convert date of 6/2/88 to
      **     Lilian representation
           MOVE 6 TO Vstring-length of IN-DATE.
           MOVE '6/2/88' TO Vstring-text of IN-DATE(1:6).
           MOVE 8 TO Vstring-length of PICSTR.
           MOVE 'MM/DD/YY' TO Vstring-text of PICSTR(1:8).
           CALL 'CEEDAYS' USING IN-DATE, PICSTR,
               LILIAN, FC.

      ** If CEEDAYS runs successfully, display result.
           IF  CEE000 of FC  THEN
               DISPLAY Vstring-text of IN-DATE
                   ' is Lilian day: ' LILIAN
           ELSE
               DISPLAY 'CEEDAYS failed with msg '
                   Msg-No of FC UPON CONSOLE
               STOP RUN
           END-IF.

       PARA-CBLDYWK.

      ** Call CEEDYWK to return the day of the week on
      ** which the Lilian date falls
           CALL 'CEEDYWK' USING LILIAN , DAYNUM , FC.

      ** If CEEDYWK runs successfully, print results
           IF CEE000 of FC  THEN
               DISPLAY 'Lilian day ' LILIAN
                   ' falls on day ' DAYNUM
                   ' of the week, which is a:'
      ** Select DAYNUM to display the name of the day
      **     of the week.
               EVALUATE DAYNUM
                 WHEN 1
                   DISPLAY 'Sunday.'
                 WHEN 2
                   DISPLAY 'Monday.'
                 WHEN 3
                   DISPLAY 'Tuesday'
                 WHEN 4
                   DISPLAY 'Wednesday.'
                 WHEN 5
                   DISPLAY 'Thursday.'
                 WHEN 6
                   DISPLAY 'Friday.'
                 WHEN 7
                   DISPLAY 'Saturday.'
               END-EVALUATE
           ELSE
               DISPLAY 'CEEDYWK failed with msg '
                   Msg-No of FC UPON CONSOLE
               STOP RUN
           END-IF.

           GOBACK.

Terms of use | Feedback

Copyright IBM Corporation 1996, 2008.
This information center is powered by Eclipse technology. (http://www.eclipse.org)