Subtract Days from a Gregorian Date

We can easily subtract number of Days from a given Gregorian Date to get a past Date using COBOL intrinsic functions.








The below code is present in the above screenshot.

01 WS-GREGORIAN-DATE           PIC 9(08). 
01 WS-SUB-DAYS                 PIC 9(08). 
01 WS-PAST-DATE                PIC 9(08). 

     COMPUTE WS-PAST-DATE  = FUNCTION DATE-OF-INTEGER            
       (FUNCTION INTEGER-OF-DATE(WS-GREGORIAN-DATE) - WS-SUB-DAYS)

No comments: