Date Function

21 Jul

COBOL has a couple  nifty date functions that allow you to add or subtract from a given date.

The INTEGER-OF-DATE function converts a date in the Gregorian calendar (formatted as CCYYMMDD) to an integer, allowing you to add to subtract from the date.

The DATE-OF-INTEGER function does the opposite, and converts an integer to a Gregorian date (formatted CCYYMMDD).

Here’s how I do it:

In WORKING-STORAGE SECTION:

In PROCEDURE DIVISION:

 

Easy, right?   One great place to use this is on a customer invoice.  Suppose I’m processing a customer invoice today that would have a due date of today + 30.  This is the best way of found of doing this.

Leave a Reply

Your email address will not be published. Required fields are marked *