TIME

The TIME function returns a time from a value.

Read syntax diagramSkip visual syntax diagram
>>-TIME--(--expression--)--------------------------------------><

expression
An expression that returns a value of one of the following built-in data types: a time, a timestamp, a character string, or a graphic string.

If expression is a character or graphic string, it must not be a CLOB or DBCLOB, and its value must be a valid string representation of a time or timestamp. For the valid formats of string representations of times and timestamps, see String representations of datetime values.

The result of the function is a time. If the argument can be null, the result can be null; if the argument is null, the result is the null value.

The other rules depend on the data type of the argument:

  • If the argument is a time:

    The result is that time.

  • If the argument is a timestamp:

    The result is the time part of the timestamp.

  • If the argument is a character string:

    The result is the time or time part of the timestamp represented by the character string. When a string representation of a time is SBCS with a CCSID that is not the same as the default CCSID for SBCS data, that value is converted to adhere to the default CCSID for SBCS data before it is interpreted and converted to a time value.

    When a string representation of a time is mixed data with a CCSID that is not the same as the default CCSID for mixed data, that value is converted to adhere to the default CCSID for mixed data before it is interpreted and converted to a time value.

Note

Syntax alternatives: The CAST specification should be used to increase the portability of applications. For more information, see CAST specification.

Example

  • Select all notes from the IN_TRAY sample table that were received at least one hour later in the day (any day) than the current time.
      SELECT *
        FROM IN_TRAY
        WHERE TIME(RECEIVED) >= CURRENT TIME + 1 HOUR