How to get system date using cql query in cassandra

I want to get the data that relates to today's date, I tried under it

select * from tablename where fieldname = dateof(now());

This query gives the date and system time, so the result will be incorrect.

How can I get only the current (today's) date?

+4
source share
1 answer

According to your question, the column name of the tablename family uses the timestamp field name as the primary key. In this case, each row is identified by a timestamp, not a date, so you cannot request a date.

, , -. , :

USE test;

create table posts(username varchar, 
    time timeuuid, 
    post_text varchar, 
    primary key(username, time)
);

insert into posts(username, time, post_text) 
values ('me', now(), 'Example');

insert into posts(username, time, post_text) 
values ('me', now(), 'Example');

select username, dateOf(time), post_text from posts;

:

enter image description here

, , :

, dateOf (), post_text time >= minTimeuuid ('2014-04-23 00:00') < minTimeuuid ('2014-04-24 00:00') username = 'me';


:

http://cassandra.apache.org/doc/cql3/CQL.html#usingdates

http://christopher-batey.blogspot.nl/2013/05/time-series-based-queries-in-cassandra.html

+2

Source: https://habr.com/ru/post/1523292/


All Articles