TIME

The TIME function returns a time from a value.

Read syntax diagramSkip visual syntax diagramTIME (expression)
expression
An expression that returns a value of one of the following built-in data types: Start of changea date,End of change a time, a timestamp, a character string, or a graphic string.

If expression is a character or graphic string, its value must be a valid string representation of a Start of changedateEnd of change, time, or timestamp. Start of changeIf expression is a valid string representation of a date, it must be one of the IBM SQL standard formats.End of change For the valid formats of string representations of dates, 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:

  • Start of changeIf the argument is a date:

    The result is midnight.

    End of change
  • 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 or graphic string:

    The result is the time represented by the string or the time part of the timestamp value represented by the string.

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