ODBC date, time, and timestamp data
You can use extended SQL syntax for date, time, and timestamp data in a vendor escape clause to make the definitions portable in your SQL statements.
The following extended SQL syntax defines date, time,
and timestamp data respectively.
- d
- Indicates that value is a date in the yyyy-mm-dd format.
- t
- Indicates that value is a time in the hh:mm:ss format.
- ts
- Indicates that value is a timestamp in the yyyy-mm-dd hh:mm:ss[.ffffffffffff] format.
- value
- Specifies your user data.
Example: You can use either of the following forms
of the escape clause to issue a query on the EMPLOYEE table. In this
example, a vendor escape clause specifies the data for the predicate
in each query.
- Short-form syntax:
SELECT * FROM EMPLOYEE WHERE HIREDATE={d '2004-03-29'}
- Long-form syntax:
SELECT * FROM EMPLOYEE WHERE HIREDATE=--(*vendor(Microsoft),product(ODBC) d '2004-03-29' *)--
You can use the ODBC vendor escape clauses for date, time, and timestamp literals in input parameters with a C data type of SQL_C_CHAR.
To determine if a data source supports date, time, or
timestamp data, call SQLGetTypeInfo()
. If a data
source supports any of these data types, the ODBC driver for that
data source supports a corresponding vendor escape clause.