两个日期和两次之间的查询

时间:2017-08-21 17:54:51

标签: postgresql hour minute

我正在尝试查询特定的时间范围,例如:

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'的行。

谢谢!

1 个答案:

答案 0 :(得分:1)

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'