查询中的相对日期



我对Elasticsearch SQL有此查询。它似乎是标准的SQL。这是代码:

SELECT * FROM index WHERE date > '00:00 2019-07-31'

我希望它是相对的,因此可以每天运行查询并显示最后30天。这可能吗?

我认为您应该能够使用 current_date Intervel 来完成您想要的。

SELECT * FROM index WHERE date > CURRENT_DATE - INTERVAL '30' DAY

请参阅:https://www.elastic.co/guide/en/elasticsearch/reference/6.7/sql-functions-datetime.html

最新更新