Hi
Suppose I have a date field declared as x(10).
I need to perform a manipulation on this date and for that purpose I need to convert it to integer.
I tried the INTEGER-OF-DATE function for this date.
But I am getting error saying the parameter for the function is invalid .
I doubt the issue is because the date I am passing as input is of the format YYYY-MM-DD but the function expects input as YYYYMMDD.
So how do I handle this ?
WORKING-STORAGE SECTION.
01 WS-VARS.
05 WS-SOURCE PIC X(10) VALUE '2019-10-31'.
05 WS-SOURCE-R REDEFINES WS-SOURCE
PIC 9999B99B99.
05 REDEFINES WS-SOURCE.
10 WS-SRC-1 PIC 9(04).
10 PIC X(01).
10 WS-SRC-2 PIC 9(02).
10 PIC X(01).
10 WS-SRC-3 PIC 9(02).
05 WS-TARGET PIC 9(08).
05 WS-INT-DATE PIC 9(07).
PROCEDURE DIVISION.
COMPUTE WS-TARGET = WS-SRC-1 * 10000 +
WS-SRC-2 * 100 +
WS-SRC-3.
COMPUTE WS-INT-DATE = FUNCTION INTEGER-OF-DATE (WS-TARGET).
DISPLAY WS-SOURCE ' ' WS-TARGET ' ' WS-INT-DATE.
MOVE WS-SOURCE-R TO WS-TARGET.
COMPUTE WS-INT-DATE = FUNCTION INTEGER-OF-DATE (WS-TARGET).
DISPLAY WS-SOURCE ' ' WS-TARGET ' ' WS-INT-DATE.