This document covers the following topics:
The date and time system variables listed below may be specified in the following places:
The contents of date and time system variables as generated by Natural are non-modifiable, which means that in a Natural program you cannot assign another value to any of them.
All date system variables contain the current date. The format of the date is different for each date variable, as indicated below.
Date Variable | Format/Length | Date Format* |
---|---|---|
*DATD | A8 | DD.MM.YY |
*DAT4D | A10 | DD.MM.YYYY |
*DATE | A8 | DD/MM/YY |
*DAT4E | A10 | DD/MM/YYYY |
*DATG | A15 | DDmonthnameYYYY (Gregorian date) |
*DATI | A8 | YY-MM-DD |
*DAT4I | A10 | YYYY-MM-DD |
*DATJ | A5 | YYJJJ (Julian date) |
*DAT4J | A7 | YYYYJJJ (Julian date) |
*DATN | N8 | YYYYMMDD |
*DATU | A8 | MM/DD/YY |
*DAT4U | A10 | MM/DD/YYYY |
*DATV | A11 | DD-MON-YYYY |
*DATVS | A9 | DDMONYYYY |
*DATX | D | internal date format |
* D = day, J = Julian day, M = month, Y = year, MON =
leading three bytes of the month's name as in
*DATG
At runtime, the content of a time system variable is evaluated anew each time the variable is referenced in a Natural program. The format of the time is different for each time variable, as indicated below.
Time Variable | Format/Length | Explanation |
---|---|---|
*TIMD (r) | N7 | Can only be used in conjunction with a previous
SETTIME statement.
Contains the time that has elapsed after the
If |
*TIME | A10 | Contains the time of day in the format HH:II:SS.T (*). |
*TIME-OUT | N5 | Contains the number of seconds remaining before the
current transaction will be timed out (only available with Natural Security).
|
*TIMESTMP | B8 |
Machine-internal store clock value as provided by the
mainframe For more information on the meaning of this value, refer to the IBM documentation. The processing of store clock values is described in Programming Guide > Further Programming Aspects > Processing of Store Clock Values. |
*TIMESTMPX | B16 |
Machine-internal store clock value as provided by the
mainframe For more information on the meaning of this value, refer to the IBM documentation. The processing of extended store clock values is described in Programming Guide > Further Programming Aspects > Processing of Store Clock Values. |
*TIMN | N7 | Contains the time of day in format HHIISST (*). |
*TIMX | T | Contains the time of day in internal time format. |
* H = hour, I = minute, S = second, T = tenth of a second.
** Example 'DATIVAR': Date and time system variables ************************************************************************ DEFINE DATA LOCAL 1 #DATE (D) 1 #TIME (T) END-DEFINE * WRITE NOTITLE 'DATE IN FORMAT DD.MM.YYYY ' *DAT4D / 'DATE IN FORMAT DD/MM/YYYY ' *DAT4E / 'DATE IN FORMAT DD-MON-YYYY ' *DATV / 'DATE IN FORMAT DDMONYYYY ' *DATVS / 'DATE IN GREGORIAN FORM ' *DATG / 'DATE IN FORMAT YYYY-MM-DD ' *DAT4I / 'DATE IN FORMAT YYYYDDD ' *DAT4J / 'DATE IN FORMAT YYYYMMDD ' *DATN (AD=L) / 'DATE IN FORMAT MM/DD/YYYY ' *DAT4U / 'DATE IN INTERNAL FORMAT ' *DATX (DF=L) /// 'TIME IN FORMAT HH:II:SS.T ' *TIME / 'TIME IN FORMAT HHIISST ' *TIMN (AD=L) / 'TIME IN INTERNAL FORMAT ' *TIMX / 'TIME IN STORE CLOCK FORMAT ' *TIMESTMP / 'TIME IN EXT. STCK FORMAT ' *TIMESTMPX / * MOVE *DATX TO #DATE ADD 14 TO #DATE WRITE 'CURRENT DATE' *DATX (DF=L) 3X 'CURRENT DATE + 14 DAYS ' #DATE (DF=L) * MOVE *TIMX TO #TIME ADD 100 TO #TIME WRITE 'CURRENT TIME' *TIMX 5X 'CURRENT TIME + 10 SECONDS' #TIME * END
Output of program DATIVAR
:
DATE IN FORMAT DD.MM.YYYY 02.12.2021 DATE IN FORMAT DD/MM/YYYY 02/12/2021 DATE IN FORMAT DD-MON-YYYY 02-Dec-2021 DATE IN FORMAT DDMONYYYY 02Dec2021 DATE IN GREGORIAN FORM 02December 2021 DATE IN FORMAT YYYY-MM-DD 2021-12-02 DATE IN FORMAT YYYYDDD 2021336 DATE IN FORMAT YYYYMMDD 20211202 DATE IN FORMAT MM/DD/YYYY 12/02/2021 DATE IN INTERNAL FORMAT 2021-12-02 TIME IN FORMAT HH:II:SS.T 14:12:43.2 TIME IN FORMAT HHIISST 1412432 TIME IN INTERNAL FORMAT 14:12:43 TIME IN STORE CLOCK FORMAT DAB39D476A7E3405 TIME IN EXT. STCK FORMAT 00DAB39D476A7E340500000008150001 CURRENT DATE 2021-12-02 CURRENT DATE + 14 DAYS 2021-12-16 CURRENT TIME 14:12:43 CURRENT TIME + 10 SECONDS 14:12:53