Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Timestamp to date using Cassandra query

Tags:

cassandra

I need to convert timestamp '1998/02/12 00:00:00 to data 1998-02-12' using Cassandra query. Can anyone help me on this. Is it possible or not?

like image 767
NkRaj Avatar asked Oct 27 '25 19:10

NkRaj


1 Answers

You can use toDate function in cql to get date out of datetime. \

For example, if your table entry looks like:

 id          | datetime                        | value
-------------+---------------------------------+-------
 22170825421 | 2018-02-15 14:06:01.000000+0000 |  50

You can run the following query:

select id, datetime, toDate(datetime) as day, value  from datatable;

and it will give you:

 id          | datetime                        | day        | value
-------------+---------------------------------+------------+-------
 22170825421 | 2018-02-15 14:06:01.000000+0000 | 2018-02-15 |  50
like image 133
farazmateen Avatar answered Oct 30 '25 13:10

farazmateen