IBM Support

Example of How to Get the Current Date/Time in a COBOL ILE Program

Troubleshooting


Problem

This document includes an example of using the FUNCTION CURRENT-DATE in COBOL ILE.

Resolving The Problem

This document includes an example of using the FUNCTION CURRENT-DATE in COBOL ILE.

Disclaimer: This is only an example. IBM accepts no responsibility for its correctness.

IDENTIFICATION DIVISION.
        PROGRAM-ID. TEST6.
         DATE-WRITTEN. Oct 16, 2012.
         DATE-COMPILED.
        ENVIRONMENT DIVISION.
        CONFIGURATION SECTION.
         SOURCE-COMPUTER. IBM-AS400.
         OBJECT-COMPUTER. IBM-AS400.
         FILE-CONTROL.
   
   
        DATA DIVISION.
         FILE SECTION.
         WORKING-STORAGE SECTION.
         01 WS-CURRENT-DATE-DATA.
           05  WS-CURRENT-DATE.
               10  WS-CURRENT-YEAR         PIC 9(04).
               10  WS-CURRENT-MONTH        PIC 9(02).
               10  WS-CURRENT-DAY          PIC 9(02).
           05  WS-CURRENT-TIME.
               10  WS-CURRENT-HOURS        PIC 9(02).
               10  WS-CURRENT-MINUTE       PIC 9(02).
               10  WS-CURRENT-SECOND       PIC 9(02).
               10  WS-CURRENT-MILLISECONDS PIC 9(02).
         PROCEDURE DIVISION.
         MAIN-LINE SECTION.
         0000.
          PERFORM A-INIT.
          PERFORM B-MAIN.
         9999.
          STOP RUN.
         A-INIT SECTION.
         A-100.
         B-MAIN SECTION.
         B-100.
             MOVE FUNCTION CURRENT-DATE to WS-CURRENT-DATE-DATA
             DISPLAY WS-CURRENT-DATE-DATA.

Internal Use Only

WEBSPHERE DEV STUDIO V610 (5761WDS40)

[{"Product":{"code":"SGYQGH","label":"IBM i"},"Business Unit":{"code":"BU009","label":"Systems - Server"},"Component":"Programming (Languages- compilers- tools)","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"Version Independent","Edition":""}]

Historical Number

649094873

Document Information

Modified date:
17 June 2018

UID

nas8N1010731