Sign in

docs RPG Reference

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 yearsEquivalent 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 yearsFormat with 4-digit years, same separatorsFormat 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 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.