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.
| 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 | |
| SQL_C_TYPE_TIMESTAMP_EXT | None 5 | Data | 20 | 00000 |
| SQL_C_TYPE_TIMESTAMP_EXT_TZ7 | None5 | Data | 24 | 00000 |
| Notes:
|
||||
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).