DB2 Version 9.7 for Linux, UNIX, and Windows

TIME scalar function

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

The schema is SYSIBM.

The TIME function returns a time from a value.

The argument must be a DATE, TIME, TIMESTAMP, or a valid string representation of a date, time, or timestamp that is not a CLOB or DBCLOB.

Only Unicode databases support an argument that is a graphic string representation of a time or a timestamp. In a Unicode database, if a supplied argument is a graphic string, it is first converted to a character string before the function is executed.

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 DATE or string representation of a date:
    • The result is midnight.
  • 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 string representation of time or timestamp:
    • The result is the time represented by the string.

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