Reputation: 1614
I have a sql table called morecrimes. I would like to select every record that occurred after 10pm and before 6am regardless of date.
I know I should use datepart but cannot quite get it to fire
There is a column is called date and has values like '2013-09-13 16:45:59'
Is the below SQL on the right track?
SELECT datepart('hour',date)>22
from morecrimes
Upvotes: 0
Views: 921
Reputation: 8709
SELECT *
FROM morecrimes
WHERE datepart('hour',date)>=22
OR datepart('hour',date)<6
Upvotes: 1