Como obter a data/hora atual em um COBOL?
IDENTIFICATION DIVISION. PROGRAM-ID. COBLDATE. DATE-WRITTEN. SEP 2, 1990. DATE-COMPILED. SEP 2, 1990. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. IBM-ZOS. OBJECT-COMPUTER. IBM-ZOS. 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. 0000-MAIN-PARA. INITIALIZE WS-CURRENT-DATE-DATA. MOVE FUNCTION CURRENT-DATE TO WS-CURRENT-DATE-DATA. DISPLAY WS-CURRENT-DATE-DATA. 9999-MAIN-EXIT. STOP RUN. |
Quando você compila e executa o programa acima, ele produz o seguinte resultado -
2020122818242863-0000 |