jlwollinger
jlwollinger

Reputation: 90

Query between two dates and two times

I'm trying to query a specific range of time, Eg.:

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

The expected result would be productions that began at '2017/05/15 00:15' to '2017/05/15 15:00' and that began at '2017/05/16 00:15' until '2017/05/16 15:00', excluding lines from '2017/05/15 15:01' until '2017/05/16 00:14'.

Thanks!

Upvotes: 0

Views: 3185

Answers (1)

Clodoaldo Neto
Clodoaldo Neto

Reputation: 125464

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'

Upvotes: 3

Related Questions