INTEGER-OF-DATE Function [ HP COBOL II/XL Reference Manual ] MPE/iX 5.0 Documentation
HP COBOL II/XL Reference Manual
INTEGER-OF-DATE Function
The INTEGER-OF-DATE function converts a date in the Gregorian calendar
from standard date form (YYYYMMDD) to integer date form. The function
type is integer.
Syntax
FUNCTION INTEGER-OF-DATE (parameter-1)
Parameters
parameter-1 Must be an integer of the form YYYYMMDD, whose
value is determined as follows:
(YYYY * 10000) + (MM * 100) + DD
where YYYY represents the year in the Gregorian
calendar and must be an integer greater than 1600.
MM represents a month and must be a positive
integer less than thirteen. DD represents a day
and must be a positive integer less than 32 ; DD
must be valid for the specified month and year
combination.
Return Value
The returned value is an integer that is the number of days the date
represented by parameter-1 succeeds December 31, 1600 in the Gregorian
calendar.
Example
The following example shows both the INTEGER-OF-DATE and DATE-OF-INTEGER
functions. First the year-month-day form of the date is converted to an
integer using INTEGER-OF-DATE. This integer represents the number of days
since December 31, 1600. Then 30 is added to this number and it is
converted back to the year-month-day form.
01 INT-DATE PIC 9(8) VALUE ZERO.
01 DATE-TODAY PIC 9(8) VALUE ZERO.
01 DUE-DATE PIC 9(8) VALUE ZERO.
:
MOVE 19910220 TO DATE-TODAY.
COMPUTE INT-DATE = FUNCTION INTEGER-OF-DATE (DATE-TODAY).
DISPLAY DATE-TODAY.
DISPLAY INT-DATE.
ADD 30 TO INT-DATE.
COMPUTE DUE-DATE = FUNCTION DATE-OF-INTEGER (INT-DATE).
DISPLAY INT-DATE.
DISPLAY DUE-DATE.
The above example displays the following values. The first two lines
represent the date February 20, 1991 and the last two lines represent
March 22, 1991, 30 days later:
19910220
00142484
00142514
19910322
MPE/iX 5.0 Documentation