SQL to C conversion for date data

You can convert the date SQL data type, SQL_TYPE_DATE, to a C data type.

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

Table 1. Conversion of date SQL data to C data
fCType Test rgbValue pcbValue SQLSTATE
SQL_C_CHAR cbValueMax >= 11 Data 10 000001
cbValueMax < 11 Untouched 10 22003
SQL_C_WCHAR cbValueMax >= 22 Data 20 000001
cbValueMax < 22 Untouched 20 22003
SQL_C_TYPE_DATE None2 Data 64 000001
SQL_C_TYPE_TIMESTAMP None2 Data3 164 000001
SQL_C_TYPE_TIMESTAMP_EXT None2 Data5 204 000001
SQL_C_TYPE_TIMESTAMP_EXT_TZ None2 Data6 244 000001
SQL_C_BINARY Data length <= cbValueMax Data Data length (in bytes) 000001
Data length > cbValueMax Untouched Untouched 22003
Notes:
  1. SQLSTATE 00000 is not returned by SQLGetDiagRec(), rather it is indicated when the function returns SQL_SUCCESS.
  2. 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.
  3. The time fields of the TIMESTAMP_STRUCT structure are set to zero.
  4. This is the size of the corresponding C data type.
  5. The time fields of the TIMESTAMP_STRUCT_EXT structure are set to zero.
  6. The time and time zone fields of the TIMESTAMP_STRUCT_EXT_TZ structure are set to zero.

When the date SQL data type is converted to the character C data type, the resulting string is in the "yyyy-mm-dd” format.