I wanted to divide a trip's departure time into 4 separate "times of day" in Excel (Morning, afternoon, evening, Night)

This script is mine, and the start time column contains the time (hh:mm:ss)

```=IF(
AND([@[start_time]] >= TIME(20,0,0),
[@[start_time]] <= TIME(23,59,59)
),
"Night",
IF(
AND([@[start_time]] >= TIME(0,0,0),
[@[start_time]] < TIME(6,0,0)
),
"Night",
IF(
AND([@[start_time]] >= TIME(6,0,0),
[@[start_time]] < TIME(12,0,0)
),
"Morning",
IF(
AND([@[start_time]] >= TIME(12,0,0),
[@[start_time]] < TIME(16,0,0)
),
"Afternoon",
"Evening"
)
)
)
)```

I was wondering if there is any way to improve this function or make it easier.

Feb 7, 2023 in Others 197 views

## 1 answer to this question.

Use vlookup():

```VLOOKUP(E2,\$B\$4:\$C\$8,2,1)
```

• 63,420 points

## Is there a way to test a formula result in excel and type it only once, all within one cell and not using a user defined function?

Use the Let function: =LET(Value,A1+B2+C4+G3+B4,IF(Value>10,"No",Value)) I hope this helps ...READ MORE

## Is there an excel function to tell if a cell has a dependency?

I think there is no built-in function ...READ MORE

## Is there a way in Microsoft Excel to give specific bins different bin widths when making a histogram plot?

Excel built-in histogram tool only allows equal ...READ MORE

## Is there a way to hide excel formula using Apache POI

In Excel, hiding formulae is a feature ...READ MORE

## Date format conversion in Excel

You appear to be misunderstanding the point: ...READ MORE

## Calculate Birthdate from an age using y,m,d in Excel

Hi To Calculate the date, we can ...READ MORE