The escape sequence for date, time, and timestamp literals is:
{literal-type 'value'}
where literal-type is one of the following:
| literal-type | Meaning | Format of value |
| d | Date | yyyy-mm-dd |
| t | Time | hh:mm:ss [1] |
| ts | Timestamp | yyyy-mm-dd hh:mm:ss[.f...] [1] |
[1] The number of digits to the right of the decimal point in a time or timestamp interval literal containing a seconds component is dependent upon the seconds precision, as contained in the SQL_DESC_PRECISION descriptor field (for more information, see SQLSetDescField).
For example, both of the following SQL statements update the open date of sales order 1023 in the Orders table. The first statement uses the escape sequence syntax. The second statement uses the native syntax for a DATE column in the Rdb from Digital Equipment Corporation. This second statement is not interoperable.
UPDATE Orders
SET OpenDate={d '1995-01-15'}
WHERE OrderID=1023
UPDATE Orders
SET OpenDate='15-Jan-1995'
WHERE OrderID=1023
To determine if a driver supports the ODBC escape sequences for date, time, or timestamp literals, an application calls SQLGetTypeInfo. If the data source supports a date, time, or timestamp data type, it must also support the corresponding escape sequence.
Data sources can also support the datetime literals defined in the ANSI SQL92 specification, which are different from the ODBC escape sequences for date, time, or timestamp literals. To determine if a data source supports the ANSI literals, an application calls SQLGetInfo with the SQL_ANSI_SQL_DATETIME_LITERALS option.
To determine if a driver supports the ODBC escape sequences for interval literals, an application calls SQLGetTypeInfo. If the data source supports a datetime interval data type, it must also support the corresponding escape sequence.
Data sources can also support the datetime literals defined in the ANSI SQL92 specification, which are different from the ODBC escape sequences for datetime interval literals. To determine if a data source supports the ANSI literals, an application calls SQLGetInfo with the SQL_ANSI_SQL_DATETIME_LITERALS option.