I have a datetime column assesseddatetime, now want to use it within a case block.
I am only getting the data for last 1 day, and with in that result, want to set any row that has the time 7am onwards till 7PM as DAY and rest as NIGHT.
Is this a proper way:
(CASE WHEN CONVERT(datetime, CONVERT(VARCHAR, pas.assessmentdatetime, 108)) BETWEEN CONVERT(datetime, '07:00:00') and CONVERT(datetime,'19:00:00')
THEN 'Day'
ELSE 'Night'
END) as Shift
Thanks a lot for the helpful info.