The WHEN-COMPILED function returns the date, time, and time difference with Greenwich mean time when a program was compiled.
000010 @OPTIONS MAIN 000020*---------------------------------------------------------------------- 000030* The WHEN-COMPILED function is used to obtain the program compilation 000035* date. 000040*---------------------------------------------------------------------- 000050 IDENTIFICATION DIVISION. 000060 PROGRAM-ID. SAMPLE. 000070 DATA DIVISION. 000080 WORKING-STORAGE SECTION. 000090 01 COMPILATION-DATE. 000100 02 YEAR PIC 9(4). 000110 02 MONTH PIC 9(2). 000120 02 MONTH-DAY PIC 9(2). 000130 02 HOUR PIC 9(2). 000140 02 MINUTE PIC 9(2). 000150 02 SECOND PIC 9(2). 000160 01 EDITING-DATA. 000170 02 YEAR PIC 9(4). 000180 02 PIC X(1) VALUE "/". 000190 02 MONTH PIC 9(2). 000200 02 PIC X(1) VALUE "/". 000210 02 MONTH-DAY PIC 9(2). 000220 02 PIC X(1) VALUE SPACE. 000230 02 HOUR PIC 9(2). 000240 02 PIC X(1) VALUE ":". 000250 02 MINUTE PIC 9(2). 000260 02 PIC X(1) VALUE ":". 000270 02 SECOND PIC 9(2). 000280 PROCEDURE DIVISION. 000290*---------------------------------------------------------------------- 000300* The program compilation date and compilation time are retrieved. 000310*---------------------------------------------------------------------- 000320 MOVE FUNCTION WHEN-COMPILED TO COMPILATION-DATE. 000330*---------------------------------------------------------------------- 000340 MOVE CORRESPONDING COMPILATION-DATE TO EDITING-DATA. 000350 DISPLAY "This program was compiled " EDITING-DATA ".". 000360 END PROGRAM SAMPLE.