【发布时间】:2020-05-05 11:05:21
【问题描述】:
假设一个表有一个timestamp 列,例如
my_db=# \d l1
Tabelle »public.l1«
Spalte | Typ | Sortierfolge | NULL erlaubt? | Vorgabewert
---------------+--------------------------------+--------------+---------------+-------------
timestamp | timestamp(6) without time zone | | not null |
查询匹配的行的最有效方法是什么
<stub>
time(timestamp)>='10:00:00' and time(timestamp)<='10:30:00'
</stub>
我找不到合适的BETWEEN 声明。
【问题讨论】:
-
嗨 gies0r Postgres 的 tsrange 有帮助吗?参考stackoverflow.com/a/48117316/1123335
-
@pnorton 这看起来不合适。来自文档:tsrange — 没有时区的时间戳范围。这不是我要搜索的(因为这会在两个日期时间字段之间进行过滤)。我正在寻找的是一个范围过滤器,它忽略时间戳列的日期部分,只过滤一天中的时间。
标签: postgresql time-series timescaledb