Date, time, and timestamp data types

Date, time, and timestamp are data types that are represented in an internal form not seen by an SQL user.

Date, time, and timestamp can be represented by character string values and assigned to character string variables. The database manager recognizes the following as date, time, and timestamp values:

  • A value returned by the DATE, TIME, or TIMESTAMP scalar function.
  • A value returned by the CURRENT DATE, CURRENT TIME, or CURRENT TIMESTAMP special register.
  • A value of a character string in the ANSI/ISO standard date, time, or timestamp format, for example, DATE '1950-01-01'.
  • A character string when it is an operand of an arithmetic expression or a comparison and the other operand is a date, time, or timestamp. For example, in the predicate:
    ... WHERE HIREDATE < '1950-01-01'

    if HIREDATE is a date column, the character string '1950-01-01' is interpreted as a date.

  • A character string variable or constant used to set a date, time, or timestamp column in either the SET clause of an UPDATE statement, or the VALUES clause of an INSERT statement.

When the CURRENT TIMESTAMP special register or a variable with the TIMESTAMP data type is used with a precision greater than 6, the timestamp value is a combination of the system clock and uniqueness bits. The uniqueness bits are assigned in an ascending order. Therefore, comparison operations for timestamps with any precision will represent an accurate order of when the timestamps were assigned.