CEECBLDY: convert date to COBOL integer format
CEECBLDY converts a string that represents a date into the number of days since 31 December 1600. Use CEECBLDY to access the century window of the date and time callable services and to perform date calculations with COBOL intrinsic functions.
This service is similar to CEEDAYS except that it provides a string in COBOL integer format, which is compatible with COBOL intrinsic functions.
- input_char_date (input)
- A halfword length-prefixed character string that represents a
date or time stamp 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.
- 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, CEECBLDY reads an input_char_date of 060288 as 02 June 1988.
If delimiters such as the slash (/) appear in the picture string, you can omit leading zeros. For example, the following calls to CEECBLDY each assign the same value, 141502 (02 June 1988), to
COBINTDTE
:MOVE '6/2/88' TO DATEVAL-STRING. MOVE 6 TO DATEVAL-LENGTH. MOVE 'MM/DD/YY' TO PICSTR-STRING. MOVE 8 TO PICSTR-LENGTH. CALL CEECBLDY USING DATEVAL, PICSTR, COBINTDTE, FC.
MOVE '06/02/88' TO DATEVAL-STRING. MOVE 8 TO DATEVAL-LENGTH. MOVE 'MM/DD/YY' TO PICSTR-STRING. MOVE 8 TO PICSTR-LENGTH. CALL CEECBLDY USING DATEVAL, PICSTR, COBINTDTE, FC.
MOVE '060288' TO DATEVAL-STRING. MOVE 6 TO DATEVAL-LENGTH. MOVE 'MMDDYY' TO PICSTR-STRING. MOVE 6 TO PICSTR-LENGTH. CALL CEECBLDY USING DATEVAL, PICSTR, COBINTDTE, FC.
MOVE '88154' TO DATEVAL-STRING. MOVE 5 TO DATEVAL-LENGTH. MOVE 'YYDDD' TO PICSTR-STRING. MOVE 5 TO PICSTR-LENGTH. CALL CEECBLDY USING DATEVAL, PICSTR, COBINTDTE, 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>
, theYY
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_Integer_date (output)
- A 32-bit binary integer that represents 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) that indicates the result of this service.
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
- Call CEECBLDY only from COBOL programs that use the returned value
as input to COBOL intrinsic functions. Unlike CEEDAYS, there is no
inverse function of CEECBLDY, because it is only for COBOL users who
want to use the date and time century
window service together with COBOL intrinsic functions for date calculations.
The inverse of CEECBLDY is provided by the
DATE-OF-INTEGER
andDAY-OF-INTEGER
intrinsic functions. - To perform calculations on dates earlier than 1 January 1601, add 4000 to the year in each date, convert the dates to COBOL integer format, then do the calculation. If the result of the calculation is a date, as opposed to a number of days, convert the result to a date string and subtract 4000 from the year.
- By default, two-digit years lie within the 100-year range that starts 80 years before the system date. Thus in 2010, all two-digit years represent dates between 1930 and 2029, inclusive. You can change this default range by using the CEESCEN callable service.
Example
*************************************************
** **
** Function: Invoke CEECBLDY callable service **
** to convert date to COBOL integer format. **
** This service is used when using the **
** Century Window feature of the date and time **
** callable services 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) 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 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 Lilian day: ' INTEGER
ELSE
DISPLAY 'CEEBLDY failed with msg '
Msg-No of FC UPON CONSOLE
STOP RUN
END-IF.
*
GOBACK.