Datetime constants

A datetime constant specifies a date, time, or timestamp.

Typically, character-string constants are used to represent constant datetime values in assignments and comparisons. For information on string representations of datetime values, see String representations of datetime values. However, the ANSI/ISO SQL standard form of a datetime constant can be used to specifically denote the constant as a datetime constant instead of a string constant.

The format for the three ANSI/ISO SQL standard datetime constants are:
  • DATE 'yyyy-mm-dd'

    The data type of the value is DATE.

  • TIME 'hh:mm:ss'

    The data type of the value is TIME.

  • TIMESTAMP 'yyyy-mm-dd hh:mm:ss.nnnnnn'

    The data type of the value is TIMESTAMP.

    Trailing zeros can be truncated or omitted entirely from microseconds. If you choose to omit any digit of the microseconds portion, an implicit specification of 0 is assumed. Thus, 1990-03-02 08:30:00.10 is equivalent to 1990-03-02 08:30:00.100000.

Leading zeros must not be omitted from any part of a standard datetime constant.

Example

   DATE '2003-09-03'