I'm trying to write a where clause with a case statement that will look at @TimeType and then only return the rows that are between those time ranges. So basically I have 3 times (morning, afternoon, and evening). I'm getting a syntax error on using between. The start_time field is sql time data type. Here's what I have so far:
declare @TimeType int
select * from events
where
start_time = case
when @TimeType = 0 then start_time between '00:00:00' and '11:59:00'
when @TimeType = 1 then start_time between '12:00:00' and '16:59:00'
when @TimeType = 2 then start_time between '17:00:00' and '23:59:00'
end