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


CEEDAYS—convert date to Lilian format

CEEDAYS converts a string that represents a date into a Lilian format, which represents a date as the number of days from the beginning of the Gregorian calendar (Friday, 14 October, 1582).

Do not use CEEDAYS in combination with COBOL intrinsic functions. Use CEECBLDY for programs that use intrinsic functions.

CALL CEEDAYS syntax
Read syntax diagramSkip visual syntax diagram>>-CALL--"CEEDAYS"--USING--input_char_date,--picture_string,---->
 
>--output_Lilian_date,--fc.------------------------------------><
 
input_char_date (input)
A halfword length-prefixed character string that represents a date or timestamp, in a format conforming to that specified by picture_string.

The character string must contain between 5 and 255 characters, inclusive. input_char_date can contain leading or trailing blanks. Parsing for a date begins with the first nonblank character (unless the picture string itself contains leading blanks, in which case CEEDAYS skips exactly that many positions before parsing begins).

After parsing a valid date, as determined by the format of the date specified in picture_string, CEEDAYS ignores all remaining characters. Valid dates range between and include 15 October 1582 to 31 December 9999.

picture_string (input)
A halfword length-prefixed character string, indicating the format of the date specified in input_char_date.

Each character in the picture_string corresponds to a character in input_char_date. For example, if you specify MMDDYY as the picture_string, CEEDAYS reads an input_char_date of 060288 as 02 June 1988.

If delimiters such as a slash (/) appear in the picture string, leading zeros can be omitted. For example, the following calls to CEEDAYS each assign the same value, 148155 (02 June 1988), to lildate:

 

CALL CEEDAYS USING '6/2/88'  , 'MM/DD/YY', lildate, fc.
CALL CEEDAYS USING '06/02/88', 'MM/DD/YY', lildate, fc.
CALL CEEDAYS USING '060288'  , 'MMDDYY'  , lildate, fc.
CALL CEEDAYS USING '88154'   , 'YYDDD'   , lildate, fc.

Whenever characters such as colons or slashes are included in the picture_string (such as HH:MI:SS YY/MM/DD), they count as placeholders but are otherwise ignored.

If picture_string includes a Japanese Era symbol <JJJJ>, the YY position in input_char_date is replaced by the year number within the Japanese Era. For example, the year 1988 equals the Japanese year 63 in the Showa era.

output_Lilian_date (output)
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.

If input_char_date does not contain a valid date, output_Lilian_date is set to 0 and CEEDAYS terminates with a non-CEE000 symbolic feedback code.

Date calculations are performed easily on the output_Lilian_date, because it is an integer. Leap year and end-of-year anomalies do not affect the calculations.

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

Table 87. CEEDAYS symbolic conditions
Symbolic feedback code Severity Message number Message text
CEE000 0 The service completed successfully.
CEE2EB 3 2507 Insufficient data was passed to CEEDAYS or CEESECS. The Lilian value was not calculated.
CEE2EC 3 2508 The date value passed to CEEDAYS or CEESECS was invalid.
CEE2ED 3 2509 The era passed to CEEDAYS or CEESECS was not recognized.
CEE2EH 3 2513 The input date passed in a CEEISEC, CEEDAYS, or CEESECS call was not within the supported range.
CEE2EL 3 2517 The month value in a CEEISEC call was not recognized.
CEE2EM 3 2518 An invalid picture string was specified in a call to a date/time service.
CEE2EO 3 2520 CEEDAYS detected nonnumeric data in a numeric field, or the date string did not match the picture string.
CEE2EP 3 2521 The <JJJJ>, <CCCC>, or <CCCCCCCC> year-within-era value passed to CEEDAYS or CEESECS was zero.

Usage notes

Example

CBL LIB
      *******************************************
      **                                       **
      ** Function: CEEDAYS - convert date to   **
      **                     Lilian format     **
      **                                       **
      *******************************************
       IDENTIFICATION DIVISION.
       PROGRAM-ID. CBLDAYS.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  CHRDATE.
           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 CHRDATE.
       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  LILIAN                  PIC S9(9) BINARY.
       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.
      *************************************************
      ** Specify input date and length               **
      *************************************************
           MOVE 16 TO Vstring-length of CHRDATE.
           MOVE '1 January 2005'
               TO Vstring-text of CHRDATE.

      *************************************************
      ** Specify a picture string that describes     **
      ** input date, and the picture string's length.**
      *************************************************
           MOVE 25 TO Vstring-length of PICSTR.
           MOVE 'ZD Mmmmmmmmmmmmmmz YYYY'
                   TO Vstring-text of PICSTR.

      *************************************************
      ** Call CEEDAYS to convert input date to a     **
      ** Lilian date                                 **
      *************************************************
           CALL 'CEEDAYS' USING CHRDATE, PICSTR,
                                LILIAN, FC.

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

           GOBACK.

Example: date-and-time picture strings

related references
Picture character terms and strings


Terms of use | Feedback

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