Unable to coerce ‘2012/11/11’ to a formatted date (long)

cassandracqlcql3cqlshcsv

I am new to Cassandra cql (cqlsh 4.1.1, Cassandra 2.0.8.39, CQL spec 3.1.1, Thrift protocol 19.39.0) – using the cql COPY command to a table from a CSV formatted file and I get the following error:
Bad Request: unable to coerce '2012/11/11' to a formatted date (long).
How do I change a column using cql so that it accepts the date from my CSV file?

Best Answer

as Brian said, there are CQL timestamp type to follow to get CQL query running. Sometimes it looks like quite weird indeed ! I've got the same issue few weeks ago with a date time insert like this one :

INSERT INTO my_table (id,lastvisitdate) VALUES (1682221,'2012-03-25 02:26:04');

I got this error : Bad Request: unable to coerce '2012-03-25 02:26:04' to a formatted date (long) ! mmmm... so bad as the date time seems to be correct !

After many tries and before going nuts, I've just added a Z at the end of the time, Z stands for Zulu time which is also UTC and GMT :

INSERT INTO my_table (id,lastvisitdate) VALUES (1682221,'2012-03-25 02:26:04Z');

Yessss ! It works ! So do not forget the timezone in your date time values, it could be helpful ! ;-)