首页 > 解决方案 > QuestDB 中的自定义时间范围?

问题描述

我目前正在做类似的查询

where startTs > '2021-04-18T00:00:00.000000Z'
      and startTs <= '2021-05-17T00:00:00.000000Z'

这不是 1 个月的数据,而是大约 25 天的间隔。我想知道是否有更短的语法来查询 QuestDB 中的时间戳之间的数据。

标签: questdb

解决方案


较短的语法是

where startTs > '2021-04-18'
      and startTs <= '2021-05-17'

所以0时间是可选的。时间可以指定到任何精度

where startTs > '2021-04-18T12'
      and startTs <= '2021-05-17T12'

也有特殊的语法来查询 29 天的间隔,但它包括开始微秒,2021-04-18T00:00:00.000000Z不包括结束微秒2021-05-17T00:00:00.000000Z

where startTs IN '2021-04-18;29d'

推荐阅读