ODBC Datetime Format

The ODBC API defines escape sequences to represent date and time values, which ODBC calls timestamp data. This ODBC timestamp format is also supported by the OLE DB language definition (DBGUID-SQL) supported by the Microsoft OLE DB Provider for SQL Server. Applications using the ADO, OLE DB, and ODBC-based APIs can use this ODBC timestamp format to represent dates and times.

ODBC timestamp escape sequences are of the format:

{ literal_type 'constant_value' }


Specifies the type of the escape sequence. Timestamps have three literal_type specifiers:

d = date only

t = time only

ts = timestamp (time + date)

' constant_value '

Is the value of the escape sequence. constant_value must follow these formats for each literal_type.

literal_type constant_value format






yyyy-mm-dd hh:mm:ss[.fff]

These are examples of ODBC time and date constants:

{ ts '1998-05-02 01:23:56.123' }

{ d '1990-10-02' }

{ t '13:33:41' }

Do not confuse the ODBC and OLE DB timestamp data type name with the Transact-SQL timestamp data type name. The ODBC and OLE DB timestamp data type records dates and times. The Transact-SQL timestamp data type is a binary data type with no time-related values. For more information, see timestamp (Transact-SQL).

Community Additions