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?
Asked
Active
Viewed 9,998 times
2 Answers
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
-
1To get both date and time, you may use `dateof(mintimeuuid(unixtime))`: https://stackoverflow.com/a/31301133/1097104 – Juuso Ohtonen Apr 28 '22 at 06:12
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