ACCEPT System Date
ACCEPT System Date Example
Scenario - Receiving system date in different formats.
Code -
----+----1----+----2----+----3----+----4----+----5----+
IDENTIFICATION DIVISION.
PROGRAM-ID. ACCPTDT.
AUTHOR. MTH.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-VAR.
05 WS-DATE-YYMMDD PIC 9(06).
05 WS-DATE-YYYYMMDD PIC 9(08).
PROCEDURE DIVISION.
* Receiving system date in default format.
ACCEPT WS-DATE-YYMMDD FROM DATE.
* Receiving system date in YYYYMMDD.
ACCEPT WS-DATE-YYYYMMDD FROM DATE YYYYMMDD.
DISPLAY 'DATE YYMMDD : ' WS-DATE-YYMMDD
DISPLAY 'DATE YYYYMMDD: ' WS-DATE-YYYYMMDD.
STOP RUN.
Output -
DATE YYMMDD : 240507 DATE YYYYMMDD: 20240507
Explaining Example -
In the above example:
- It first accepts the system date in the default format (YYMMDD) and stores it in WS-DATE-YYMMDD.
- It accepts the system date in the YYYYMMDD format and stores it in WS-DATE-YYYYMMDD.
- Finally, it displays both date values and terminates the program.