【问题标题】:Inserting date using yesterday/tomorrow into Cassandra使用昨天/明天将日期插入 Cassandra
【发布时间】:2020-01-09 14:36:33
【问题描述】:

我正在尝试根据当前日期将日期插入 Cassandra。

create table mobileTimeSeries (
deviceid text,
date date,
PRIMARY KEY(deviceid, date));

insert into mobileTimeSeries (deviceid, date) values ('test', toDate(now()));

这行得通,但我想知道是否可以做类似的事情

insert into mobileTimeSeries (deviceid, date) values ('test', toDate(now()-1));
insert into mobileTimeSeries (deviceid, date) values ('test', toDate(now()+1));

我只是得到这个错误不匹配的输入 '+' 期望 ')' (... 'tablet',toDate(now()) [+]...)

不确定这是否可能。谢谢

【问题讨论】:

    标签: cassandra cqlsh


    【解决方案1】:

    您可以在应用中计算日期,然后将其作为日期插入,而不是使用 now()。

    在 4.0+ 中 CASSANDRA-11936 之后,您可以执行 now() - 1d 类似的事情。

    【讨论】:

      猜你喜欢
      • 2019-10-30
      • 1970-01-01
      • 1970-01-01
      • 2019-09-29
      • 2017-01-11
      • 2014-10-26
      • 1970-01-01
      • 2018-07-20
      • 1970-01-01
      相关资源
      最近更新 更多