RE: C/C++ API - cannot insert a date value into a table or select a date value from a table

Hi
I am using the C/C++ API on Windows from Datastax.

I have created a table that has several columns including some columns that are defined as time, timestamp and date.

The time and timestamp columns are fine for inserting and selecting, however when I try to either insert or do a select on the date column I get a bind error of CASS_ERROR_LIB_INVALID_VALUE_TYPE.

After performing a select I use this code to get the data::
value = cass_row_get_column_by_name(m_row, “tDate”);

cass_int32_t dte = 0;
CassError rc = cass_value_get_int32(value, &dte);

rc is set to CASS_ERROR_LIB_INVALID_VALUE_TYPE

Anyone any ideas?

Phillip

Have you tried with cass_uint32_t and cass_value_get_uint32? According to our documentation ( Data Types | ScyllaDB Docs ): Values of the date type are encoded as 32-bit unsigned integers representing a number of days with “the epoch” at the center of the range (2^31).

Hi
Yep I was using int32 instead of uint32, changed my code and it is all working now.

Thanks
Phillip