Reputation: 81
I am trying to get something like below in SQL
if (current time in between 5AM to 3PM )
then print "firsshift"
else (current time in between 5AM to 3PM)
then print "second shift"
Upvotes: 0
Views: 56
Reputation: 3363
DECLARE @CurrentTime AS TIME
SET @CurrentTime = GETDATE()
SELECT @CurrentTime AS CurrentTime,
CASE
WHEN @CurrentTime BETWEEN '5:00:00' AND '15:00:00' THEN
'First Shift'
ELSE
'Second Shift'
END AS WhichShift
Upvotes: 2