fbpx
Search
Close this search box.

Figure out slot from given time [quick tip]

Share

Facebook
Twitter
LinkedIn

Here is an interesting scenario.

Let’s say you are looking at a time, like 9:42 AM and want to know which 15 minute slot it fits into. The answer is 9:30 – 9:45. But how would you get this answer thru Excel formulas?

timeslot-from-time-excel-formulas

Excel formula to find slot from time:

Assuming A1 contains the input time, here is one formula that tells you the time slot.

=TEXT(TIME(HOUR(A1),INT(MINUTE(A1)/15)*15,0),”hh:mm”)&” – “&TEXT(TIME(HOUR(A1),(INT(MINUTE(A1)/15)+1)*15,0),”hh:mm”)

Whoa!, that’s long. Let’s examine the inner workings of this beast.

Logic: We need to figure out both lower & upper boundaries of fifteen minute slot for time in A1. The lower boundary is quotient of A1/15 minutes multiplied by 15. For example, 09:42’s lower boundary is 09:30. The upper boundary is lower boundary + 15 minutes.

Implementation:

INT(MINUTE(A1)/15) * 15 portion: this part of the formula tells us the minutes. We extract the minute part of A1 (using MINUTE(A1)) and divide it with 15. We then take only the integer portion of this division and multiply that with 15 again. This gives us the minute portion of lower boundary of our time slot.

TIME(HOUR(A1), INT(..)*15, 0) portion: We then create a time value using the TIME formula by using the same hour as A1, minutes from lower boundary calculation using the INT(…)* 15  and 0 as seconds.

TEXT(TIME(…), “hh:mm”) portion: This will convert the time value to text formatted as hh:mm.

So far we have constructed the lower boundary of time slot. The upper boundary part of the formula is similar with one minor change. Go figure it out.

How to find 1 hour time slot?

Let’s say you want to find the time slot on hourly basis, then what?

Below formula does the job.

=HOUR(A1)&”:00 – ” & (HOUR(A1)+1) & “:00”

What if your time slots are not uniformly spaced?

The above approaches work fine as long as your time slots are uniformly spaced (ie 15 minutes, 1 hour, 4 hours or 8 hour apart). What if you have a unique set up? Something like this:

non-uniform-time-slots-how-to

In that case you can use the range lookup method.

Related: read about pricing tier lookup too.

So there you go. For more information about working with date & time values in Excel, check out below material.

A challenge for you:

How would you write the 15 minute time slot formula? Can you figure out other ways to calculate it? Please share your formulas in the comments section. Your time starts now!

Facebook
Twitter
LinkedIn

Share this tip with your colleagues

Excel and Power BI tips - Chandoo.org Newsletter

Get FREE Excel + Power BI Tips

Simple, fun and useful emails, once per week.

Learn & be awesome.

Welcome to Chandoo.org

Thank you so much for visiting. My aim is to make you awesome in Excel & Power BI. I do this by sharing videos, tips, examples and downloads on this website. There are more than 1,000 pages with all things Excel, Power BI, Dashboards & VBA here. Go ahead and spend few minutes to be AWESOME.

Read my storyFREE Excel tips book

Excel School made me great at work.
5/5

– Brenda

Excel formula list - 100+ examples and howto guide for you

From simple to complex, there is a formula for every occasion. Check out the list now.

Calendars, invoices, trackers and much more. All free, fun and fantastic.

Advanced Pivot Table tricks

Power Query, Data model, DAX, Filters, Slicers, Conditional formats and beautiful charts. It's all here.

Still on fence about Power BI? In this getting started guide, learn what is Power BI, how to get it and how to create your first report from scratch.

letter grades from test scores in Excel

How to convert test scores to letter grades in Excel?

We can use Excel’s LOOKUP function to quickly convert exam or test scores to letter grades like A+ or F. In this article, let me explain the process and necessary formulas. I will also share a technique to calculate letter grades from test scores using percentiles.

17 Responses to “Figure out slot from given time [quick tip]”

  1. MF says:

    How about using Floor and Ceiling?
    =TEXT(FLOOR(A1,TIME(,15,)),"HH:MM")& " - " & TEXT(CEILING(A1+(MOD(MINUTE(A1),15)=0)*(TIME(,1,)),TIME(,15,)),"HH:MM")

  2. esg says:

    continuing from MF:
    =TEXT(FLOOR(A1,1/96),"HH:MM")& " - " & TEXT(FLOOR(A1,1/96)+1/96,"HH:MM")
    (72 chars) although I would prefer to use a named range (one cell) called slot that contains the time per slot, in out case, 1/96
    =TEXT(FLOOR(A1,slot),"HH:MM")& " - " & TEXT(FLOOR(A1,slot)+slot,"HH:MM")
    This too, weighs in at 72 chars

  3. Stef@n says:

    Hi
    =ROUND(A1*96,0)/96
    as a basis for more creativity 😉
    Regards
    Stef@n

  4. K. Mann says:

    The mround function works fairly well for this problem...
    =TEXT(MROUND(A1,"0:15")-((MROUND(A1,"0:15")>A1)*("0:15")),"h:mm AM/PM")&" - "&TEXT(MROUND(A1,"0:15")+((MROUND(A1,"0:15")<A1)*("0:15")),"h:mm AM/PM")

  5. Haz says:

    =TEXT(MROUND(A1,"0:15"),"hh:mm")&" - "&TEXT(MROUND(A1,"0:15")+TIME(,15,),"hh:mm")

  6. SunnyKow says:

    My solution to question 2 would be using VLOOKUP.
    =TEXT(VLOOKUP(D1,A1:B9,1,TRUE),"hh:mm")&"-"&TEXT(VLOOKUP(D1,A1:B9,2,TRUE),"hh:mm")

  7. HSoomro says:

    Nice.

  8. Jude Shyju says:

    =TEXT(FLOOR(A1,0.25/24),"hh:mm")&" - "&TEXT(CEILING(A1,0.25/24),"hh:mm")

  9. Jason Morin says:

    =TEXT(FLOOR(A1,1/24/4),"h:mm")&"-"&TEXT(FLOOR(A1,1/24/4)+1/24/4,"h:mm")

  10. Rajib says:

    Upper Bound: MROUND("Input Date","Increment")
    Lower Bound: MROUND("Input Date",2*"Increment")

    Increment in the format: "0:05" for 5 minutes

  11. JEFF says:

    WHAT IF YOUR UNIFORM RANGE CROSSES MIDNIGHT? HOW WOULD YOU FIGURE THAT OUT?

    0200 - 0600
    0600 - 1000
    1000 - 1400
    1400 - 1800
    1800 - 2200
    2200 - 0200

    thanks

  12. yoav says:

    =A1-MOD(A1,A2)

    A1 is the current time.
    in B1 I wrote 00:15, or 01:00...

  13. Srinivas P says:

    Friends,

    I need a formula or any trick in displaying time into slots My requirement is like this......

    COL A COL B
    8:00 Am Morning
    8:20 Pm Night
    8:40 Am Morning
    11:20 Am Afternoon
    10:23 Am Morning
    11:00 Am Afternoon

    I want to display the time slot or intervals in COL B based on times from COL A using any lookup.
    how do i achieve this ..\\

    Pls help me in getting the desired result. Does VLOOKUP work for this scenario.if yes ,how would i define the range from the PREDEFINED RANGE

    ANY SUGGESTION OR Help is highly appreciated.. Kindly suggest me the solution..

  14. Bryan says:

    assume time slot is interval by 6 hours.
    if the user input time is between 00:00 to 05:59 then show TS 1 as result.
    if the user input time is between 06:00 to 11:50 then show TS 2,
    if the user input time is between 12:00 to 17:59 then show TS3 and
    if the user input time is between 18:00 to 23:59 then show TS 4

    try many way but cant write out the formula

Leave a Reply