HP 3000 Manuals

DATE-OF-INTEGER Function [ HP COBOL II/XL Reference Manual ] MPE/iX 5.0 Documentation


HP COBOL II/XL Reference Manual

DATE-OF-INTEGER Function 

The DATE-OF-INTEGER function converts a date in the Gregorian calendar
from integer date form to standard date form (YYYYMMDD). The function
type is integer.

Syntax 

     FUNCTION DATE-OF-INTEGER (parameter-1)

Parameters 

parameter-1           Is a positive integer that represents a number of
                      days succeeding December 31, 1600 in the Gregorian
                      calendar.

Return Value 

The returned value represents the ISO Standard date equivalent of the
integer specified in parameter-1.

The returned value is in the form YYYYMMDD, where YYYY represents a year
in the Gregorian calendar, MM represents the month of that year, and DD
represents the day of that month.

For example, the value 19910723 represents July 23, 1991.

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