我试图查询特定的时间范围,例如:

SELECT * FROM production
WHERE
production.begin BETWEEN '2017/05/15' AND '2017/05/16'
AND production.begin BETWEEN '00:15' AND '15:00'

预期结果将是从“2017/05/15 00:15”到“2017/05/15 15:00”的生产,从“2017/05/16 00:15”到“2017/05/16 15:00”的生产,不包括从“2017/05/15 15:01”到“2017/05/16 00:14”的生产线。
谢谢!

最佳答案

select *
from production
where
    production.begin::date between '2017/05/15' and '2017/05/16'
    and
    production.begin::time between '00:15' and '15:00'

关于postgresql - 在两个日期和两次之间查询,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45803041/

10-16 08:13