CEECBLDY—Convert date to COBOL Integer format

CEECBLDY converts a string representing a date into a COBOL Integer format, which is the number of days since 1 January 1601. This service is similar to CEEDAYS, except that it provides a string in COBOL Integer format, which is compatible with ANSI intrinsic functions. Use CEECBLDY to access the century window of Language Environment and to perform date calculations with COBOL intrinsic functions for programs compiled with the INTDATE(ANSI) compiler option.

Call CEECBLDY only from COBOL programs that use the returned value as input for COBOL intrinsic functions. You should not use the returned value with other Language Environment callable services, nor should you call CEECBLDY from any non-COBOL programs. Unlike CEEDAYS, there is no inverse function for CEECBLDY, because it is only for COBOL users who want to use the Language Environment century window service together with COBOL intrinsic functions for date calculations. The inverse function for CEECBLDY is provided by the DATE-OF-INTEGER and DAY-OF-INTEGER intrinsic functions.

To handle dates earlier than 1601, add 4000 to each year, convert to Integer, calculate, subtract 4000 from the result, and then convert back to character format. By default, 2-digit years lie within the 100-year range starting 80 years prior to the system date. Thus, in 1995, all 2-digit years represent dates between 1915 and 2014, inclusive. You can change this default range by using the CEESCEN callable service.
Read syntax diagramSkip visual syntax diagram
Syntax

>>-CEECBLDY--(--input_char_date--,--picture_string--,----------->

>--output_ANSI_date--,--)--------------------------------------><

input_char_date (input)
A halfword length-prefixed character string (VSTRING) representing 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 CEECBLDY 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, CEECBLDY ignores all remaining characters. Valid dates range between and include 01 January 1601 to 31 December 9999. See Table 1 for a list of valid picture character terms that can be specified in input_char_date.
picture_string (input)
A halfword length-prefixed character string (VSTRING), 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, CEECBLDY reads an input_char_date of 060288 as 02 June 1988. If delimiters such as the slash (/) appear in the picture string, leading zeros can be omitted. For example, the following calls to CEECBLDY would each assign the same value, 148155 (02 June 1988), to COBINTDATE:
MOVE '6/2/88' TO DATEVAL.
MOVE 'MM/DD/YY' TO PICSTR.
CALL CEECBLDY USING DATEVAL, PICSTR, COBINTDATE, fc);

MOVE '06/02/88' TO DATEVAL.
MOVE 'MM/DD/YY' TO PICSTR.
CALL CEECBLDY USING DATEVAL, PICSTR, COBINTDATE, fc);

MOVE '060288' TO DATEVAL.
MOVE 'MMDDYY' TO PICSTR.
CALL CEECBLDY USING DATEVAL, PICSTR, COBINTDATE, fc);

MOVE '88154' TO DATEVAL.
MOVE 'YYDDD' TO PICSTR.
CALL CEECBLDY USING DATEVAL, PICSTR, COBINTDATE, 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. See Table 1 for a list of valid picture character terms and Table 2 for examples of valid picture strings.

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. See Table 2 for an additional example. See also Table 3 for a list of Japanese Eras supported by CEEDATE.

If picture_string includes era symbol <CCCC> or <CCCCCCCC>, the YY position in input_char_date is replaced by the year number within the era. See Table 2 for an additional example.

output_Integer_date (output)
A 32-bit binary integer representing the COBOL Integer date, the number of days since 31 December 1600. For example, 16 May 1988 is day number 141485. If input_char_date does not contain a valid date, output_Integer_date is set to 0 and CEECBLDY terminates with a non-CEE000 symbolic feedback code. Date calculations are performed easily on the output_Integer_date, because output_Integer_date is an integer. Leap year and end-of-year anomalies do not affect the calculations.
fc (output)
A 12-byte feedback code, optional in some languages, that indicates the result of this service. If you choose to omit this parameter, refer to Invoking callable services for the appropriate syntax to indicate that the feedback code was omitted.

The following symbolic conditions can arise from this service:

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 non-numeric data in a numeric field, or the date string did not match the picture string.
CEE2EP 3 2521 The (<JJJJ>) or (<CCCC>) year-within-era value passed to CEEDAYS or CEESECS was zero.

Usage notes

  • The probable cause for receiving message number 2518 is a picture string that contains an invalid DBCS string. You should verify that the data in the picture string is correct.
  • z/OS UNIX consideration—In multithread applications, CEECBLDY affects only the calling thread.

For more information

  • See the INTDATE COBOL compiler installation option in the appropriate version of the COBOL programming guide in the COBOL library at Enterprise COBOL for z/OS library for information about how to get ANSI integer values from COBOL Intrinsic Functions that are compatible with the Language Environment callable services CEEDAYS and CEEDATE.
  • See CEESCEN—Set the century window for more information about the CEESCEN callable service.
  • See Table 1 for a list of valid picture character terms that can be specified in input_char_date.

Examples

  1. Following is an example of CEECBLDY called by COBOL.
           CBL LIB,QUOTE
          *Module/File Name: IGZTCBLD
          *************************************************
          **                                             **
          ** Function: Invoke CEECBLDY callable service  **
          ** to convert date to COBOL Integer format.    **
          ** This service is used when using the         **
          ** Lang. Environ. Century Window                **
          ** mixed with COBOL Intrinsic Functions.       **
          **                                             **
          *************************************************
           IDENTIFICATION DIVISION.
           PROGRAM-ID. CBLDY.
    
           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  INTEGER                 PIC S9(9) BINARY.
           01  NEWDATE                 PIC 9(8).
           01  FC.
               02  Condition-Token-Value.
               COPY  CEEIGZCT.
                   03  Case-1-Condition-ID.
                       04  Severity    PIC S9(4) BINARY.
                       04  Msg-No      PIC S9(4) BINARY.
                   03  Case-2-Condition-ID
                           REDEFINES Case-1-Condition-ID.
                       04  Class-Code  PIC S9(4) BINARY.
                       04  Cause-Code  PIC S9(4) BINARY.
                   03  Case-Sev-Ctl    PIC X.
                   03  Facility-ID     PIC XXX.
               02  I-S-Info            PIC S9(9) BINARY.
           PROCEDURE DIVISION.
    
           PARA-CBLDAYS.
          *************************************************
          ** Specify input date and length               **
          *************************************************
               MOVE 25 TO Vstring-length of CHRDATE.
               MOVE "1 January 00"
                   to Vstring-text of CHRDATE.      
          *************************************************
          ** Specify a picture string that describes     **
          ** input date, and set the string's length.    **
          *************************************************
               MOVE 23 TO Vstring-length of PICSTR.
               MOVE "ZD Mmmmmmmmmmmmmmz YY"
                         TO Vstring-text of PICSTR.
    
          *************************************************
          ** Call CEECBLDY to convert input date to a    **
          ** COBOL Integer date                          **
          *************************************************
               CALL "CEECBLDY" USING CHRDATE, PICSTR,
                                     INTEGER, FC.
    
          *************************************************
          ** If CEECBLDY runs successfully, then compute **
          **     the date of the 90th day after the      **
          **     input date using Intrinsic Functions    **
          *************************************************
               IF CEE000 of FC  THEN
                   COMPUTE INTEGER = INTEGER + 90
                   COMPUTE NEWDATE = FUNCTION
                       DATE-OF-INTEGER (INTEGER)
                   DISPLAY NEWDATE
                       " is ANSI day: " INTEGER
               ELSE
                   DISPLAY "CEECBLDY failed with msg "
                       Msg-No of FC UPON CONSOLE
                   STOP RUN
               END-IF.
    
               GOBACK.