Time Data Type
Time fields have a predetermined size and format. They can be defined on the definition specification. Leading and trailing zeros are required for all time data.
Time constants or variables used in comparisons or assignments do not have to be in the same format or use the same separators. Also, times used for I/O operations such as input fields, output fields or key fields are also converted (if required) to the necessary format for the operation.
The default internal format for time variables is *ISO. This default internal format can be overridden globally by the control specification keyword TIMFMT, temporarily changed by /SET and /RESTORE directives, and individually set by the definition specification keyword TIME or TIMFMT.
The hierarchy used when determining the internal time format and separator
for a time field is
- From the TIME or TIMFMT keyword specified on the definition specification
- From the most recent /SET directive containing a TIMFMT keyword that has not been restored by a /RESTORE directive.
- From the TIMFMT keyword specified on the control specification
- *ISO
For examples on how to code time fields, see the examples in:
Table 1 shows the time formats supported
and their separators.
Note: The separator '&' indicates that a blank is used as the separator.
For example, a time field defined with TIME(*HMS&)
will have blanks as the separators.
RPG Format Name | Description | Format (Default Separator) | Valid Separators | Length | Example |
---|---|---|---|---|---|
*HMS | Hours:Minutes:Seconds | hh:mm:ss | : . , & | 8 | 14:00:00 |
*ISO | International Standards Organization | hh.mm.ss | . | 8 | 14.00.00 |
*USA | IBM® USA Standard. AM and PM can be any mix of upper and lower case. | hh:mm AM or hh:mm PM | : | 8 | 02:00 PM |
*EUR | IBM European Standard | hh.mm.ss | . | 8 | 14.00.00 |
*JIS | Japanese Industrial Standard Christian Era | hh:mm:ss | : | 8 | 14:00:00 |
Table 2 lists the *LOVAL, *HIVAL, and default values for
all the time formats.
RPG Format Name | Description | *LOVAL | *HIVAL | Default Value |
---|---|---|---|---|
*HMS | Hours:Minutes:Seconds | 00:00:00 | 24:00:00 | 00:00:00 |
*ISO | International Standards Organization | 00.00.00 | 24.00.00 | 00.00.00 |
*USA | IBM USA Standard. AM and PM can be any mix of upper and lower case. | 00:00 AM | 12:00 AM | 00:00 AM |
*EUR | IBM European Standard | 00.00.00 | 24.00.00 | 00.00.00 |
*JIS | Japanese Industrial Standard Christian Era | 00:00:00 | 24:00:00 | 00:00:00 |