The value represented by the RPG IV *LOVAL and *HIVAL figurative constants corresponds directly to the type of field with which they are used. For date fields, January 1, 0001 is considered *LOVAL and December 31, 9999 is considered *HIVAL. Figure C.2 shows the *LOVAL and *HIVAL representations for DATE, TIME, and TIMESTAMP fields. Figure C.3 contains the *LOVAL representation for all available date formats.
Data Type | *LOVAL | *HIVAL |
---|---|---|
DATE | D'0001-01-01' | D'9999-12-31' |
TIME | T'00:00:00' | T'24:00:00' |
TIMESTAMP | 0001-01-01-00.00.00.000000 | 9999-12-31-24.00.00.000000 |
The *LOVAL for the TIME data type is interesting. The value T'24:00:00' represents midnight. This is a valid time using the 24-hour military time format and represents the *HIVAL value. However, the value T'00:00:00' is a fictitious time. Most digital timers, however, use T'24:00:00' to display the instant of midnight. When incrementing, they go from T'23:59:59' to T'24:00:00' followed by T'00:00:01'. See Table C.3.
Date Format | Lowest Date Value | |
---|---|---|
Masked | Raw | |
*YMD | D'40/01/01' | 400101 |
*DMY | D'01/01/40' | 010140 |
*JUL | D'40/001' | 40001 |
*ISO | D'0001-01-01' | 00010101 |
*USA | D'01/01/0001' | 01010001 |
*EUR | D'01.01.0001' | 01010001 |
*JIS | D'0001-01-01' | 00010101 |
This problem is amplified when the *USA time format is used. Under *USA time, T'00:00 am' is used for *LOVAL, and T'12:00 AM' is used for *HIVAL. Because there is no such thing as 12:00 A.M., it's difficult to work with these values.
The primary OS/400 user interface language, DDS supports date, time, and timestamp variables presented to the user. The data-type used to indicate a date value is "L", a time value is "T," and a timestamp value is "Z."
When a date, time, or timestamp value (herein subsequently and collectively referred to as date) is added to a device file, the operating system manages how the date is displayed or printed.
When using date fields in a display file, the date follows the same restrictions and requirements as database date fields. The DATFMT and DATSEP keywords are also used similar to database date fields.
When entering a date value into a workstation device file, the end-user is allowed to enter the date with or without the separators. When a date value is displayed, it includes the separator specified by the DATSEP or TIMSEP keywords.
There is one additional DDS keyword called MAPVAL (Map Date/Time Value). This keyword allows non-date values to be translated into valid date values. For example, if the end-user enters blanks into a date field on the workstation, those blanks can be automatically translated to valid date value. The MAPVAL keyword syntax is as follows:
mapval( (program-value1 output-value1 ) (program-value2 output-value2)…)
The program-valuen is the from value. It is the value that is sent from or received into the program. The output-valuen is the to value. It is the value that is written to the workstation or print device. The program-value and the output-value must contain valid date or time values. These values must be in the format specified by the DATFMT or TIMFMT keywords.
The MAPVAL keyword acts like a translation table. When an output operation to the device is performed, the MAPVAL list is searched for a value that matches that of the output field. If a match is not detected, the field's value is sent to the output device unchanged. If a match is detected, the field's value is translated to the output-value by searching the MAPVAL list for the first program-value that matches the value in the date field. Then, the corresponding output-value is sent to the device.