This sample demonstrates how to obtain the current system date and time via the conceptual data items DATE, DATE YYYYMMDD, DAY, DAY YYYYDDD, DAY-OF-WEEK, and TIME.
The program uses the ACCEPT statement to get the values of the conceptual data items listed above, and formats various displays of date and time values.
This is an older method of obtaining the current date and time which is still present in many existing legacy Cobol applications. Although an older method, it offers two pieces of information the instrinsic function CURRENT-DATE does not:
- day of the week
- time down to the hundredths of a second.
On the other hand, this method does not provide us with the timezone offset fromm UTC. For a comparison of methods, see the DATE1 sample program.
The format looks like this:
Today is Tuesday, the 19th of January, 2021
The format looks like this (representing January 19, 2021):
01/19/21
The format looks like this (representing January 19, 2021):
19.01.21
The format looks like this::
07:52:18.29