【问题标题】:Operator does not exist: tstzrange && timestamp with time zone运算符不存在:带有时区的 tstzrange && 时间戳
【发布时间】:2019-07-09 11:35:11
【问题描述】:

跑步:

SELECT tstzrange( '2019-05-01', '2019-05-09' ) && '2019-05-01'::timestamptz

我收到错误消息:

SQL Error [42883]: ERROR: operator does not exist: tstzrange && timestamp with time zone
Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.

为什么没有范围与点重叠?
这个操作看起来很合理

【问题讨论】:

    标签: postgresql


    【解决方案1】:

    为什么没有范围与点重叠?

    因为这不是“重叠”的定义方式。如果要测试单个时间戳值是否在某个范围内,则需要使用包含运算符@>

    SELECT tstzrange( '2019-05-01', '2019-05-09' ) @> '2019-05-01'::timestamptz
    

    【讨论】:

    • 目前实现为next,但是为什么“重叠”没有定义与点的交集?可能是邮件列表讨论
    • @EugenKonkov:嗯,标准的overlaps操作符也是这样定义的。
    猜你喜欢
    • 2017-06-21
    • 1970-01-01
    • 2020-06-07
    • 1970-01-01
    • 2011-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-22
    相关资源
    最近更新 更多