+ Reply to Thread
Results 1 to 6 of 6

Check if a time is within two times (using first time as the starting time)

  1. #1
    Registered User
    Join Date
    10-18-2012
    Location
    Surrey, BC
    MS-Off Ver
    Excel 2016
    Posts
    84

    Check if a time is within two times (using first time as the starting time)

    Hi there, I am having some difficulty checking to see if a time is within two other times, I need to use a start and end time. The code I am using checks from the lowest to the largest time values. Note: I minus off 15 minutes so the last time value isn't true.
    I am using the formula below:
    Please Login or Register  to view this content.
    This works as long as the ending time doesn't go past midnight.

    As you can see in the image, all hours are being recorded properly except for John... his hours have been picked up in reverse. I need his hours to show 'YES' for 20:00,21:00,22:00,23:00,00:00,01:00,02:00,03:00.

    time.jpg

    Is it possible for me to do this?

    My goal is to count the number of people working during each hour of the day... for scheduling verification.

    Thanks
    Craig

  2. #2
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Check if a time is within two times (using first time as the starting time)

    You could try tossing in another IF clause. In B10:

    =IF(B$9=MEDIAN($D2,IF($E2>$D2,$E2-15/60/24,1+$E2-15/60/24),B$9),"Yes","No")

    I think that returns the results you're looking for...
    If your problem has been solved, please use "Thread Tools" to mark the thread as "Solved".

    If you're grateful for this site's existence and would like to contribute to the community, please consider posting something hilarious in our joke thread:
    https://www.excelforum.com/the-water...ke-thread.html

  3. #3
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Check if a time is within two times (using first time as the starting time)

    Try this formula in B10 copied across and down as required


    =IF((B$9>=$D2)+(B$9<$E2)+($D2>$E2)=2,"Yes","No")
    Audere est facere

  4. #4
    Registered User
    Join Date
    10-18-2012
    Location
    Surrey, BC
    MS-Off Ver
    Excel 2016
    Posts
    84

    Re: Check if a time is within two times (using first time as the starting time)

    This is one step closer... adding the additional if statement changed 20:00, 21:00, 22:00 and 23:00 to YES (perfect) but it did not change 00:00, 1:00, 2:00 or 3:00.

    time.jpg

    Does it help that I know the number of hours they are working (Column B) along with the start and end times? I know if they are working 8 hours (Column B), can this be combined with the start time to determine where the range falls? I also know if the hours overlap into the next day (past midnight) (Column C).



    Craig

  5. #5
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Check if a time is within two times (using first time as the starting time)

    Ah, I didn't realize that the next day's hours should be included. Apologies. The solution from daddylonglegs looks like it should work

  6. #6
    Registered User
    Join Date
    10-18-2012
    Location
    Surrey, BC
    MS-Off Ver
    Excel 2016
    Posts
    84

    Re: Check if a time is within two times (using first time as the starting time)

    Yes daddylonglegs formula worked great... much appreciated to the both of you.
    Now I will decipher to see how it works.

    Thanks again to the both of you!

    Craig

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 03-04-2016, 06:38 PM
  2. Replies: 6
    Last Post: 11-26-2014, 10:35 PM
  3. [SOLVED]Time/Date calculation to check response time
    By tailz in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 09-01-2013, 10:20 AM
  4. Check time is between 2 times and highlight cell
    By Tetley09 in forum Excel General
    Replies: 3
    Last Post: 10-17-2012, 07:46 AM
  5. Replies: 7
    Last Post: 10-20-2011, 01:43 PM
  6. Replies: 4
    Last Post: 01-25-2009, 11:25 AM
  7. Way to Subtract Time From Time? Not Diff Between Times.
    By TomBrooklyn in forum Excel General
    Replies: 1
    Last Post: 07-31-2008, 08:57 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1