Example of Calculating a Stale Date

To calculate if a date is so far in the past that it invalidates the dated piece (such as a cheque), you could use the SUBTRACT-DURATION intrinsic function as follows:

01 YYYYMMDD                    FORMAT DATE "@Y%m%d".
01 STALE-DATE                  FORMAT DATE "%m/%d/@Y".
01 cheque-date                 FORMAT DATE "%m/%d/@Y"  VALUE "03/09/1997".
   .
   .
   .
    MOVE FUNCTION CURRENT-DATE(1:8) TO YYYYMMDD.
    MOVE FUNCTION SUBTRACT-DURATION (YYYYMMDD DAYS 180) TO STALE-DATE.
    IF STALE-DATE > cheque-date THEN
       DISPLAY 'Cheque date, ' cheque-date ', is stale-dated.'
       DISPLAY 'The stale-date is: ' STALE-DATE
    END-IF.

Assuming that the current date is October 8, 1997, the output of the above program would be:


Cheque date, 03/09/1997, is stale-dated.
The stale date is: 04/11/1997 


[ Top of Page | Previous Page | Next Page | Contents | Index ]