Blog Archive

RPGLE date formats - iSeries Date data type

A date is a three-part value (year, month, and day) designating a point in time under the Gregorian calendar20, which is assumed to have been in effect from the year 1 A.D. The range of the year part is 0001 to 9999. The date formats *JUL, *MDY, *DMY, and *YMD can only represent dates in the range 1940 through 2039. The range of the month part is 1 to 12. The range of the day part is 1 to x, where x is 28, 29, 30, or 31, depending on the month and year.

The internal representation of a date is a string of 4 bytes that contains an integer. The integer (called the Scaliger number) represents the date. The length of a DATE column as described in the SQLDA is 6, 8, or 10 bytes, depending on which format is used. These are the appropriate lengths for string representations for the value.

Date strings

A string representation of a date is a character or a Unicode graphic string that starts with a digit and has a length of at least 6 characters. Trailing blanks can be included. Leading zeros can be omitted from the month and day portions when using the IBM(R) SQL standard formats. Each IBM SQL standard format is identified by name and includes an associated abbreviation (for use by the CHAR function). Other formats do not have an abbreviation to be used by the CHAR function. The separators for two-digit year formats are controlled by the date separator (DATSEP) parameter. Valid string formats for dates are listed in Table below.

The database manager recognizes the string as a date when it is either:
  • In the format specified by the default date format, or
  • In the ANSI/ISO SQL standard date format, or
  • In one of the IBM SQL standard date formats, or
  • In the unformatted Julian format
Formats for String Representations of Dates
Format Name Abbreviation Date Format Example
ANSI/ISO SQL standard date format (-) - DATE 'yyyy-mm-dd' DATE '1987-10-12'
International Standards Organization (*ISO) ISO 'yyyy-mm-dd' '1987-10-12'
IBM USA standard (*USA) USA 'mm/dd/yyyy' '10/12/1987'
IBM European standard (*EUR) EUR '' '12.10.1987'
Japanese industrial standard Christian era (*JIS) JIS 'yyyy-mm-dd' '1987-10-12'
Unformatted Julian - 'yyyyddd' '1987285'
Julian (*JUL) - 'yy/ddd' '87/285'
Month, day, year (*MDY) - 'mm/dd/yy' '10/12/87'
Day, month, year (*DMY) - 'dd/mm/yy' '12/10/87'
Year, month, day (*YMD) - 'yy/mm/dd' '87/12/10'

The default internal format for date variables is *ISO. This default internal format can be overridden globally by the control specification keyword DATFMT and individually by the definition specification keyword DATFMT.
The hierarchy used when determining the internal date format and separator for a date field is
  1. From the DATFMT keyword specified on the definition specification
  2. From the DATFMT keyword specified on the control specification
  3. *ISO
There are three kinds of date data formats, depending on the range of years that can be represented. This leads to the possibility of a date overflow or underflow condition occurring when the result of an operation is a date outside the valid range for the target field. The formats and ranges are as follows:

Number of Digits in Year Range of Years
2 (*YMD, *DMY, *MDY, *JUL) 1940 to 2039
3 (*CYMD, *CDMY, *CMDY) 1900 to 2899
4 (*ISO, *USA, *EUR, *JIS, *LONGJUL) 0001 to 9999

RPG-defined date formats and separators for Date data type

Format Name Description Format (Default Separator) Valid Separators Length Example
2-Digit Year Formats
*MDY Month/Day/Year mm/dd/yy / - . , '&' 8 01/15/96
*DMY Day/Month/Year dd/mm/yy / - . , '&' 8 15/01/96
*YMD Year/Month/Day yy/mm/dd / - . , '&' 8 96/01/15
*JUL Julian yy/ddd / - . , '&' 6 96/015
4-Digit Year Formats
*ISO International Standards Organization yyyy-mm-dd - 10 1996-01-15
*USA IBM USA Standard mm/dd/yyyy / 10 01/15/1996
*EUR IBM European Standard . 10 15.01.1996
*JIS Japanese Industrial Standard Christian Era yyyy-mm-dd - 10 1996-01-15

Table below lists the *LOVAL, *HIVAL, and default values for all the RPG-defined date formats.

Date Values

Format name Description *LOVAL *HIVAL Default Value
2-Digit Year Formats
*MDY Month/Day/Year 01/01/40 12/31/39 01/01/40
*DMY Day/Month/Year 01/01/40 31/12/39 01/01/40
*YMD Year/Month/Day 40/01/01 39/12/31 40/01/01
*JUL Julian 40/001 39/365 40/001
4-Digit Year Formats
*ISO International Standards Organization 0001-01-01 9999-12-31 0001-01-01
*USA IBM USA Standard 01/01/0001 12/31/9999 01/01/0001
*EUR IBM European Standard 01.01.0001 31.12.9999 01.01.0001
*JIS Japanese Industrial Standard Christian Era 0001-01-01 9999-12-31 0001-01-01

Source: IBM Information center

Recommended Reading


  1. Very Good info!! :)

    Thanks for sharing

  2. Enjoy! Date to make yourself happy. Who you date is entirely your choice. Whether she is a fellow geek or not, she must be someone you want to spend time with or you will be happy to

  3. Ahí tenés Mateo

  4. With the invention of smartphones, watching movies and tv shows have become so easy.
    We no longer have to wait for the shows to be telecasted on tv.
    Instead we can just download some great apps like Playbox, which provides free streaming of videos and tv shows.
    It is becoming very popular day by day and you must check it out.
    PlayBox HD Apk Download