SQL to C conversion for timestamp data

You can convert the timestamp SQL data type, SQL_TYPE_TIMESTAMP, to a C data type.

The following table shows information about converting timestamp SQL data to C data.

Table 1. Conversion of timestamp SQL data to C data
fCType Test rgbValue pcbValue SQLSTATE
SQL_C_CHAR Display size < cbValueMax Data Data length (in bytes) 000001
19 <= cbValueMax <= Display size Truncated data2 Data length (in bytes) 01004
cbValueMax < 19 Untouched Data length (in bytes) 22003
SQL_C_WCHAR Display size < cbValueMax Data Data length (in bytes) 000001
38 <= cbValueMax <= Display size Truncated data2 Data length (in bytes) 01004
cbValueMax < 38 Untouched Data length (in bytes) 22003
SQL_C_TYPE_DATE None Truncated data3 64 01004
SQL_C_TYPE_TIME None 5 Truncated data6 64 01004
SQL_C_TYPE_TIMESTAMP None 5 Data 164 000001
Fractional seconds portion of timestamp is truncated. 5 Data2 16 01004
Start of changeSQL_C_TYPE_TIMESTAMP_EXTEnd of change Start of changeNone 5End of change Start of changeDataEnd of change Start of change20End of change Start of change00000End of change
Notes:
  1. SQLSTATE 00000 is not returned by SQLGetDiagRec(), rather it is indicated when the function returns SQL_SUCCESS.
  2. The fractional seconds of the timestamp are truncated.
  3. The time portion of the timestamp is deleted.
  4. This is the size of the corresponding C data type.
  5. The value of cbValueMax is ignored for this conversion. The driver assumes that the size of rgbValue is the size of the C data type.
  6. The date portion of the timestamp is deleted.

When the timestamp SQL data type is converted to the character C data type, the resulting string is in the "yyyy-mm-dd hh:mm:ss[.fff[fff]]” format (regardless of the precision of the timestamp SQL data type).