Problem:
Please send an example of conversion of 'YYYYMMDD' date format to integer format and then conversion to Julian date plus reverse conversion back to 'YYYYMMDD'.
Resolution:
This conversion begins with a date consisting of the year, the month and day (20040827) stored in a data item named "YYYYMMDDItem". The INTEGER-OF-DATE intrinsic function is used to convert this date into an integer value that is the number of days elapsed since December, 31, 1600, in the Gregorian calendar (147,432) with the result stored in a data item named "integerDate". Next, the DAY-OF-INTERGER intrinsic function is used to convert the "integerDate" item into a Julian date of the form YYYYDDD storing the result (2004240) in the data item named "julianDate".
Reversing this conversion is accomplished by using the INTEGER-OF-DAY intrinsic function to convert the "julianDate" data item to an integer value stored in the "integerDate" data item. Lastly, the DATE-OF-INTEGER intrinsic function is used to convert the integer value in the "integerDate" data item to a standard date form in the "YYYYMMDDItem" data item.
77 YYYYMMDDItem pic s9(8) value 20040827. *> YYYYMMDD
77 integerDate pic s9(8) value ZEROS.
77 julianDate pic s9(8) value zeros. *> YYYYDDD
procedure division.
move FUNCTION INTEGER-OF-DATE(YYYYMMDDItem) to integerDate
move FUNCTION DAY-OF-INTEGER(integerDate) to julianDate
move FUNCTION INTEGER-OF-DAY(julianDate) to integerDate
move FUNCTION DATE-OF-INTEGER(integerDate) to YYYYMMDDItem
stop run.