We can leverage the language environment callable service CEESECS which will convert timestamp to seconds.
The below code is present in the above screenshot.
01 WS-SECOND1 COMP-2.
01 WS-SECOND2 COMP-2.
01 WS-TIMESTAMP-1 PIC X(26).
01 WS-TIMESTAMP-2 PIC X(26).
01 WS-FORMAT PIC X(26).
01 WS-DIFFERENCE PIC +9(09).
01 WS-FC-CODE.
05 FC-SEVERITY PIC S9(4) COMP.
05 FC-MESSAGE PIC S9(4) COMP.
05 FILLER PIC X(08).
MOVE '2004-03-23-15.35.39.838149' TO WS-TIMESTAMP-1
MOVE '2004-05-17-13.07.18.234567' TO WS-TIMESTAMP-2
MOVE 'YYYY-MM-DD-HH.MI.SS.999999' TO WS-FORMAT
CALL 'CEESECS' USING WS-TIMESTAMP-1,
WS-FORMAT,
WS-SECOND1,
WS-FC-CODE
IF FC-SEVERITY = +0
CONTINUE
ELSE
DISPLAY 'CEESECS ROUTINE ERROR'
PERFORM INHOUSE-ABEND-ROUTINE
END-IF
CALL 'CEESECS' USING WS-TIMESTAMP-2,
WS-FORMAT,
WS-SECOND2,
WS-FC-CODE
IF FC-SEVERITY = +0
CONTINUE
ELSE
DISPLAY 'CEESECS ROUTINE ERROR'
PERFORM INHOUSE-ABEND-ROUTINE
END-IF
COMPUTE WS-DIFFERENCE = WS-SECOND2 - WS-SECOND1
DISPLAY 'THE DIFFERENCE BETWEEN 2 TIMESTAMPS IS:'
WS-DIFFERENCE
No comments:
Post a Comment