CEEDATE: convert Lilian date to character format

CEEDATE converts a number that represents a Lilian date to a date written in character format. The output is a character string, such as 2010/04/23.

Read syntax diagramSkip visual syntax diagram
CALL CEEDATE syntax

>>-CALL--"CEEDATE"--USING--input_Lilian_date,------------------->

>--picture_string,--output_char_date,--fc.---------------------><

input_Lilian_date (input)
A 32-bit integer that represents the Lilian date. The Lilian date is the number of days since 14 October 1582. For example, 16 May 1988 is Lilian day number 148138. The valid range of Lilian dates is 1 to 3,074,324 (15 October 1582 to 31 December 9999).
picture_string (input)
A halfword length-prefixed character string that represents the desired format of output_char_date, for example MM/DD/YY. Each character in picture_string represents a character in output_char_date. If delimiters such as the slash (/) appear in the picture string, they are copied as is to output_char_date.

If picture_string includes a Japanese Era symbol <JJJJ>, the YY position in output_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_char_date (output)
A fixed-length 80-character string that is the result of converting input_Lilian_date to the format specified by picture_string. If input_Lilian_date is invalid, output_char_date is set to all blanks and CEEDATE terminates with a non-CEE000 symbolic feedback code.
fc (output)
A 12-byte feedback code (optional) that indicates the result of this service.
Table 1. CEEDATE 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.
CEE2EM 3 2518 An invalid picture string was specified in a call to a date/time service.
CEE2EQ 3 2522 An era (<JJJJ>, <CCCC>, or <CCCCCCCC>) was used in a picture string passed to CEEDATE, but the Lilian date value was not within the supported range. The era could not be determined.
CEE2EU 2 2526 The date string returned by CEEDATE was truncated.
CEE2F6 1 2534 Insufficient field width was specified for a month or weekday name in a call to CEEDATE or CEEDATM. Output set to blanks.

Usage note: The inverse of CEEDATE is CEEDAYS, which converts character dates to the Lilian format.

Example

CBL LIB
      ************************************************
      **                                            **
      ** Function: CEEDATE - convert Lilian date to **
      **                     character format       **
      **                                            **
      ** In this example, a call is made to CEEDATE **
      ** to convert a Lilian date (the number of    **
      ** days since 14 October 1582) to a character **
      ** format (such as 6/22/98). The result is    **
      ** displayed.  The Lilian date is obtained    **
      ** via a call to CEEDAYS.                     **
      **                                            **
      ************************************************
       IDENTIFICATION DIVISION.
       PROGRAM-ID. CBLDATE.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  LILIAN                  PIC S9(9) BINARY.
       01  CHRDATE                 PIC X(80).
       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/98 to   **
      **     Lilian representation                   **
      *************************************************
           MOVE 6 TO Vstring-length of IN-DATE.
           MOVE '6/2/98' 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.

      *************************************************
      ** Specify picture string that describes the   **
      **  desired format of the output from CEEDATE, **
      **  and the picture string's length.           **
      *************************************************
           MOVE 23 TO Vstring-length OF PICSTR.
           MOVE 'ZD Mmmmmmmmmmmmmmz YYYY' TO
                        Vstring-text OF PICSTR(1:23).

      *************************************************
      ** Call CEEDATE to convert the Lilian date     **
      **     to  a picture string.                   **
      *************************************************
           CALL 'CEEDATE' USING LILIAN, PICSTR,
                                CHRDATE, FC.

      *************************************************
      ** If CEEDATE runs successfully, display result**
      *************************************************
           IF CEE000 of FC  THEN
               DISPLAY 'Input Lilian date of ' LILIAN
                   ' corresponds to:  ' CHRDATE
           ELSE
               DISPLAY 'CEEDATE failed with msg '
                   Msg-No of FC UPON CONSOLE
               STOP RUN
           END-IF.

           GOBACK.

The following table shows the sample output from CEEDATE.

input_Lilian_date picture_string output_char_date
148138 YY 98
YYMM 9805
YY-MM 98-05
YYMMDD 980516
YYYYMMDD 19980516
YYYY-MM-DD 1998-05-16
YYYY-ZM-ZD 1998-5-16
<JJJJ> YY.MM.DD Showa 63.05.16 (in a DBCS string)
148139 MM 05
MMDD 0517
MM/DD 05/17
MMDDYY 051798
MM/DD/YYYY 05/17/1998
ZM/DD/YYYY 5/17/1998
148140 DD 18
DDMM 1805
DDMMYY 180598
DD.MM.YY 18.05.98
DD.MM.YYYY 18.05.1998
DD Mmm YYYY 18 May 1998
148141 DDD 140
YYDDD 98140
YY.DDD 98.140
YYYY.DDD 1998.140
148142 YY/MM/DD HH:MI:SS.99 98/05/20 00:00:00.00
YYYY/ZM/ZD ZH:MI AP 1998/5/20 0:00 AM
148143 WWW., MMM DD, YYYY SAT., MAY 21, 1998
Www., Mmm DD, YYYY Sat., May 21, 1998
Wwwwwwwwww, Mmmmmmmmmm DD, YYYY Saturday, May 21, 1998
Wwwwwwwwwz, Mmmmmmmmmz DD, YYYY Saturday, May 21, 1998

Example: date-and-time picture strings

related references  
Picture character terms and strings