Datetime assignments
A value assigned to a DATE column must be a date or a valid string representation
of a date. A date can only be assigned to a DATE column, a string column,
a string variable, or a date variable. A value assigned to a TIME column must
be a time or a valid string representation of a time. A time can only be assigned
to a TIME column, a string column, a string variable, or a time variable.
A value assigned to a TIMESTAMP column must be a timestamp or a valid string
representation of a timestamp. A timestamp can only be assigned to a TIMESTAMP
column, a string column, a string variable, or a timestamp variable.
When a datetime value is assigned to a string variable or column, it is
converted to its string representation. Leading zeros are not omitted from
any part of the date, time, or timestamp. The required length of the target
varies depending on the format of the string representation. If the length
of the target is greater than required, it is padded on the right with blanks.
If the length of the target is less than required, the result depends on the
type of datetime value involved and on the type of target.
- If the target is a string column, truncation is not allowed. The following
rules apply:
DATE
- The length attribute of the column must be at least 10 if the date format
is *ISO, USA, *EUR, or *JIS. If the date format is *YMD, *MDY, or *DMY, the
length attribute of the column must be at least 8. If the date format is *JUL,
the length of the variable must be at least 6.
TIME
- The length attribute of the column must be at least 8.
TIMESTAMP
- The length attribute of the column must be at least 26.
- When the target is a variable, the following rules apply:
DATE
- The length of the variable must be at least 10 if the date format is *ISO,
*USA, *EUR, or *JIS. If the date format is *YMD, *MDY, or *DMY, the length
of the variable must be at least 8. If the date format is *JUL, the length
of the variable must be at least 6.
TIME
- If the *USA format is used, the length of the variable must not be less
than 8. This format does not include seconds.
- If the *ISO, *EUR, *JIS, or *HMS time format is used, the length of the
variable must not be less than 5. If the length is 5, 6, or 7, the seconds
part of the time is omitted from the result, and SQLWARN1 is set to 'W'.
In this case, the seconds part of the time is assigned to the indicator variable
if one is provided, and, if the length is 6 or 7, blank padding occurs so
that the value is a valid string representation of a time.
TIMESTAMP
- The length of the variable must not be less than 19. If the length is
between 19 and 25, the timestamp is truncated like a string, causing the omission
of one or more digits of the microsecond part. If the length is 20, the trailing
decimal point is replaced by a blank so that the value is a valid string representation
of a timestamp.
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.