Reputation: 41
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?
Upvotes: 4
Views: 11915
Reputation: 187
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
Upvotes: 7
Reputation: 87069
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.
Upvotes: 0