Question: I have a column of time data formatted like this: `hh:mm:ss`

I want to make an IF statement that returns 1, 2 or 3 corresponding to first, second or third shift if the times fall between certain values.

```
=IF(AND(E50>8,0,0,E50<16,0,0),"First",(IF(AND(E50>=16,0,0,E50<24,0,0), "Second", "Third")))

```

That's what it looks like now, but it doesn't work.

Answer: 
Use the [CHOOSE function](https://support.office.com/en-us/article/CHOOSE-function-fce63190-b514-48cc-a7ff-c1cdaaec0907) with [HOUR](https://support.office.com/en-us/article/HOUR-function-a3afa879-86cb-4339-b1b5-2dd2d7310ac7). You should account for all possible results.

```
=choose(hour(e50)/8+1, "third", "first", "second")

```

[![enter image description here](https://i.stack.imgur.com/2GGK9.png)](https://i.stack.imgur.com/2GGK9.png)
I found this to be the simplest way to convert time into 3 shifts. The plus 1 allows for excel returning midnight to 00:59 as 0. (so in the formula below, the first six results of the choose function are `"C"` referring to night shift, then at 6am the shift changes to `"A"` day shift. and so on. `"R3"` is the cell i had the time in.

```
=CHOOSE(HOUR(R3)+1, "C", "C", "C", "C","C","C", "A", "A", "A", "A", "A", "A", "A","A","B","B","B","B","B","B","B","B","C","C")

```