DATEYY(*ALLOW | *WARN | *NOALLOW)
DATEYY(*ALLOW | *WARN | *NOALLOW)
As the year 2039 approaches, dates with 2-digit years become less and less useful. Use the DATEYY keyword to help you find where your code is using dates with 2-digit years.
*ALLOW : No messages are issued when a date format with 2-digit years is used. This is the default.
*WARN : A severity-10 warning is issued if a date format with 2-digit years is used.
*NOALLOW : A severity-30 error is issued if a date format with 2-digit years is used.
The DATEYY keyword only causes the compiler to issue warning or error messages. It does not cause the compiler to assume different date formats.
The DATEYY keyword overrides the value set by the DATEYY parameter for the CRTBNDRPG or CRTRPGMOD command.
If your code is using a format with 2-digit years and you want to change it to use a format with 4-digit years, use the following tables to determine the equivalent format.
Table 1. Equivalent 4-digit-year formats for date definitions
| Format with 2-digit years | Equivalent format with 4-digit years |
|---|---|
| *DMY | *EUR |
| *MDY | *USA |
| *YMD | *ISO or *JIS |
Table 2. Equivalent 4-digit-year formats for conversions between date data and character or numeric data
| Format with 2-digit years | Format with 4-digit years, same separators | Format with 4-digit years, only one separator |
|---|---|---|
| *DMY | *DMYY | *EUR |
| *JOBRUN | *LONGJOBRUN | |
| *JUL | *LONGJUL | |
| *MDY | *MDYY | *USA |
| *YMD | *YYMD | *ISO or *JIS |
For more information about the date formats, see Table 1.
The DATEYY keyword affects the following:
- The parameter for the DATFMT Control keyword.
- The parameter for the DATFMT File keyword.
- The parameter for the DATFMT Definition keyword.
- The the parameter for the DATE Definition keyword.
- The format of variables from externally-described files and data structures.
- The user date special words UDATE and UYEAR. Use *DATE and *YEAR instead.
- The format for the %DATE, %DEC, and %CHAR built-in functions. If the current format is *JOBRUN and you change your code so the date value has a 4-digit year, you can use the *LONGJOBRUN format to handle the new value. For examples of the *LONGJOBRUN date format, see %CHAR(date|time|timestamp {: format}), %DATE Examples, Using %DEC to convert dates, times and timestamps to numeric, TEST (Test Date/Time/Timestamp), and MOVE (Move).
- The format for the MOVE, MOVEL, and TEST(D) operation codes.
- The TIME operation code when the result field has 12 digits. Specify a 14-digit result instead.
The DATEYY keyword does not affect the DATEDIT keyword, which controls the Y edit code. The formats *DMY, *MDY, and *YMD are always allowed for the DATEDIT keyword.
Note: If you specify DATEYY(*WARN) or DATEYY(*NOALLOW), and you use embedded SQL, use the DATFMT parameter for the CRTSQLRPGI command, or the SET OPTION statement in your program to specify one of the date formats that support 4-digit years.