0
votes

I would like to store and view a timestamp column with format yyyy-mm-dd HH:mmZ. I made changes to the dattimeformat in cqlshrc file and also stored it in .cassandra folder under home. Following is the change that I made:

> [ui] ;; Whether or not to display query results with colors ; color =
> on
> 
> ;; Used for displaying timestamps (and reading them with COPY)
> 
> datetimeformat = %Y-%m-%d %H:%M%z
> 
> ;; Display timezone timezone = Etc/UTC
> 
> ;; The number of digits displayed after the decimal point for single
> and double precision numbers ;; (note that increasing this to large
> numbers can result in unusual values) ;float_precision = 5
> ;double_precision = 15
> 
> ;; Used for automatic completion and suggestions ; completekey = tab

So in cql I created a simple temp table as follows:

CREATE TABLE project_fvag.temp (
    user_name timestamp PRIMARY KEY,
    user_id decimal
) 

Now, when I do the:

 insert insert into project_fvag.temp(user_time,user_id) values('1997-21-01 00:01Z',0.2);

I get the error:

InvalidRequest: Error from server: code=2200 [Invalid query] message="Unable to coerce '1997-21-01 00:01Z' to a formatted date (long)"

also, when i view the table's past content, I see the data as

 user_time                       | user_id
---------------------------------+-----------
 2017-10-10 14:20:56.000000+0000 |       0.2
 2017-10-10 14:20:25.777000+0000 |       0.2

I would like to know why is datetime yyyy-mm-dd HH:mmZ format not working?

1

1 Answers

0
votes

The datetimeformat only used when displaying date and copy from command in cqlsh

Used for displaying timestamps (and reading them with COPY)
datetimeformat = %Y-%m-%d %H:%M:%S%z