You need to know what date is 150 days from today. Convert today to an integer date, add 150 to it and convert it back. No more checking which months you’re going through to see if it’s a 30 day or 31 day month. No more leap year calculations. It’s pretty automatic:
01 WS-TODAY PIC 9(8).
01 WS-FUTURE-DATE PIC 9(8).
Logic to get COBOL future Date
MOVE FUNCTION CURRENT-DATE (1:8) TO WS-TODAY.
COMPUTE WS-FUTURE-DATE = FUNCTION DATE-OF-INTEGER (FUNCTION INTEGER-OF-DATE (WS-TODAY) + 150)
How many days between two dates
COMPUTE is OK because we’re only using integers here.
COMPUTE WS-DAYS = FUNCTION INTEGER-OF-DATE (WS-DATE-1) – FUNCTION INTEGER-OF-DATE (WS-DATE-2)
Comments are closed.