Skip to content
Advertisement

How to use ‘between’ in CASE statement?

I need to select Shift from my production table such that if the time time is between 05:00 PM to 06:30 AM it is Shift B else its Shift A. The SQL that I have written is quite simple but does not gives me the expected results. The SQL is

The Result I get is

Shift_FK_ID
1
1
1

Where op_Date is operations date. The code was simple but can’t figure it out. Maybe it has something to do with 24 hrs format.

Help required.

Regards

Advertisement

Answer

I think you want logic like this:

There is no need to use strings for these comparisons.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement