SQL to C: Date

The identifier for the date ODBC SQL data type is:

SQL_TYPE_DATE

The following table shows the ODBC C data types to which date SQL data may be converted. For an explanation of the columns and terms in the table, see “Converting Data from SQL to C Data Types.”


C type identifier

Test

*TargetValuePtr
*StrLen_or
_IndPtr
SQL-
STATE
SQL_C_CHAR BufferLength > Character byte length

11 <= BufferLength <= Character byte length

BufferLength < 11

Data

Truncated data

Undefined

10

Length of data in bytes

Undefined

n/a

01004

22003

SQL_C_WCHAR BufferLength > Character length

11 <= BufferLength <= Character length

BufferLength < 11

Data

Truncated data

Undefined

10

Length of data in characters

Undefined

n/a

01004

22003

SQL_C_BINARY Byte length of data <= BufferLength


Byte length of data > BufferLength

Data


Undefined

Length of data in bytes


Undefined

n/a


22003

SQL_C_TYPE_DATE None [a] Data 6 [c] n/a
SQL_C_TYPE_
TIMESTAMP
None [a] Data [b] 16 [c] n/a

[a]The value of BufferLength is ignored for this conversion. The driver assumes that the size of *TargetValuePtr is the size of the C data type.

[b]The time fields of the timestamp structure are set to zero.

[c]This is the size of the corresponding C data type.

When date SQL data is converted to character C data, the resulting string is in the “yyyy-mm-dd” format. This format is not affected by the Windows country setting.