Thursday, November 1, 2012

COBOL: How can I get the date a program was compiled?


If you want to get the date of compilation of a program (for example you may want to display it to ensure you are using the correct version of the program), then you can use the special register WHEN-COMPILED. This returns the date and time of compilation as a 16 character string formatted as MM/DD/YYhh.mm.ss . You cannot modify the WHEN-COMPILED register.
 

MOVE WHEN-COMPILED TO WS-COMP-DATE.


If you are using COBOL for OS/390 then you can also use the intrinsic function WHEN-COMPILED to get the compile date. This returns a 21 character string, but only the first 16 characters are used. The string is in the format YYYYMMDDhhmmsszz (where zz is hundredths of a second)


MOVE FUNCTION WHEN-COMPILED TO WS-COMP-DATE.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.