How can I categorize time?

supersam92

New Member
Joined
May 23, 2020
Messages
7
Office Version
  1. 2019
Platform
  1. Windows
Hello, I need help please ?

I want to divide 24 hours into 4 categories:
00:00-09:14=1
09:15-11:59=2
12:00-17:14=3
17:15-23:59=4

Is there any way that I can turn a column of time into value 1/2/3/4?
E.g. 15:22 -> 3, 18:46 -> 4........

Thank you!
 
Are the times moving past midnight when you add 7 hours? If so then try

=LOOKUP(MOD(B1,1),TIMEVALUE({"00:00:00","2:15:00","6:00:00","10:15:00","17:00:00"}),{1,2,3,4,1})

In a formula, "22:00:00" + "07:00:00" is effectively "29:00:00", even though it would show in the cell as "05:00:00", it is actually 1 day and 5 hours, not just 5 hours (which the formula was looking for).
 
Upvote 0

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Are the times moving past midnight when you add 7 hours? If so then try

=LOOKUP(MOD(B1,1),TIMEVALUE({"00:00:00","2:15:00","6:00:00","10:15:00","17:00:00"}),{1,2,3,4,1})

In a formula, "22:00:00" + "07:00:00" is effectively "29:00:00", even though it would show in the cell as "05:00:00", it is actually 1 day and 5 hours, not just 5 hours (which the formula was looking for).

It works!
Amazing. Thank you very much!
 
Upvote 0

Forum statistics

Threads
1,214,986
Messages
6,122,611
Members
449,090
Latest member
vivek chauhan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top