Case statement
CASE
WHEN CONVERT(VARCHAR(8), datetime, 108) BETWEEN
’07:00:00′ AND ’14:59:00′ THEN ‘Day’
WHEN CONVERT(VARCHAR(8), datetime, 108) BETWEEN
’15:00:00′ AND ’22:59:00′ THEN ‘Evening’
ELSE ‘Night’
END AS ShiftName
You can also use Switch statement
WorkShift = SWITCH(TRUE(),[Time] >= TIME(7, 0, 0) && [Time] < TIME(15,0,0), “DAY”, [Time] >= TIME(15,0,0) && [Time] < TIME(23,0,0), “Evening”,
“Night”)