Comparing date, time, and timestamp using the Open Query File (OPNQRYF) command
A date, time, or timestamp value can be compared either with another value of the same data type or with a string representation of that data type.
All comparisons are chronological, which means the farther a time is from January 1, 0001, the greater the value of that time.
Comparisons involving time values and string representations of time values always include seconds. If the string representation omits seconds, zero seconds are implied. Comparisons involving timestamp values are chronological without regard to representations that might be considered equivalent. Thus, the following predicate is true:
TIMESTAMP ('1990-02-23-00.00.00') > '1990-02-22-24.00.00'
When a character, DBCS-open, or DBCS-either field or constant is represented as a date, time, or timestamp, the following rules apply:
Date: The length of the field or literal must be at least 8 if the date format is *ISO, *USA, *EUR, *JIS, *YMD, *MDY, or *DMY. If the date format is *JUL (yyddd), the length of the variable must be at least 6 (includes the separator between yy and ddd). The field or literal can be padded with blanks.
Time: For all of the time formats (*USA, *ISO, *EUR, *JIS, *HMS), the length of the field or literal must be at least 4. The field or literal can be padded with blanks.
Timestamp: For the timestamp format (yyyy-mm-dd-hh.mm.ss.uuuuuu), the length of the field or literal must be at least 16. The field or literal can be padded with blanks.
Parent topic:
Using Open Query File (OPNQRYF) command