jotamon
jotamon

Reputation: 1614

Selecting specific days of week within time period

I am trying to select records that occurred on Sun, Mon, Wed between 0:00 and 1:00. The dow part of this request is working but the 'hour' part does not seem to be included in the query. What have I done wrong? I feel like I am missing some parenthesis

SELECT * FROM myTable 
WHERE date_part('dow',date)=0 
    OR date_part('dow',date)=1 
    OR date_part('dow',date)=3 
    AND date_part('hour',date)<=1 
    AND date_part('hour',date)>= 0

Upvotes: 0

Views: 108

Answers (1)

Amir Keshavarz
Amir Keshavarz

Reputation: 3108

Try this :

SELECT * 
FROM myTable 
WHERE (date_part('dow',date) In(0,1,3)) AND (date_part('hour',date)<=1 AND date_part('hour',date)>= 0)

Upvotes: 1

Related Questions