2

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?

NkRaj
  • 21
  • 1
  • 2

2 Answers2

4

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
farazmateen
  • 157
  • 9
0

You can't do it directly in the Cassandra, as it accepts data as YYYY-mm-dd, so you need to use some other method (depending on language that you're using) to convert your string into this format.

Alex Ott
  • 80,552
  • 8
  • 87
  • 132