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 and individually by the definition specification keyword TIMFMT.

The hierarchy used when determining the internal time format and separator for a time field is

  1. From the TIMFMT keyword specified on the definition specification
  2. From the TIMFMT keyword specified on the control specification
  3. *ISO

For examples on how to code time fields, see the examples in:

Table 36 shows the time formats supported and their separators.

Table 36. Time formats and separators for Time data type
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 37 lists the *LOVAL, *HIVAL, and default values for all the time formats.

Table 37. Time Values
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


[ Top of Page | Previous Page | Next Page | Contents | Index ]