Rules for date, time, and timestamp assignment of host variables in SQL statements

When a date is assigned to a host variable, the date is converted to the string representation specified by the DATFMT and DATSEP parameters of the CRTSQLxxx command.

Leading zeros are not omitted from any part of the date representation. The host variable must be a fixed or variable-length character string variable with a length of at least 10 bytes for *USA, *EUR, *JIS, or *ISO date formats, 8 bytes for *MDY, *DMY, or *YMD date formats, or 6 bytes for the *JUL date format. If the length is greater than 10, the string is padded on the right with blanks. In ILE RPG and ILE COBOL, the host variable can also be a date variable.

When a time is assigned to a host variable, the time is converted to the string representation by the TIMFMT and TIMSEP parameters of the CRTSQLxxx command. Leading zeros are not omitted. The host variable must be a fixed or variable-length character string variable. If the length of the host variable is greater than the string representation of the time, the string is padded on the right with blanks. In ILE RPG and ILE COBOL, the host variable can also be a time variable.

When a timestamp is assigned to a host variable, the timestamp is converted to its string representation. Leading zeros are not omitted from any part. The host variable must be a fixed or variable-length character string variable with a length of at least 19 bytes. If the length is less than 26, the host variable does not include all the digits of the microseconds. If the length is greater than 26, the host variable is padded on the right with blanks. In ILE RPG and ILE COBOL, the host variable can also be a timestamp variable.