+ Reply to Thread
Results 1 to 18 of 18

Check if event occurs within time range

  1. #1
    Registered User
    Join Date
    09-17-2016
    Location
    ny,ny
    MS-Off Ver
    2013
    Posts
    7

    Check if event occurs within time range

    Hi,

    The events have a start time and end time (as shown in the columns). I am trying to find out which events occur between 8 PM and 8 AM.

    The problem is that the event doesn't have to start or end between 8 PM and 8 AM. As an example, if an event starts at 7 PM and ends at 9 AM, a formula tracking starting and end time does not capture the event as having occurred.

    I have attached a sample of the data.

    Thanks in advance.
    Attached Files Attached Files

  2. #2
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Check if event occurs within time range

    Hi excellinginlife and welcome to the forum.

    Does this do what you want? In C2:C12
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Row\Col
    A
    B
    C
    1
    est begin time est end time
    2
    12/31/2000 7:00 AM
    12/31/2000 8:00 AM
    0:00
    3
    12/13/2000 10:00 PM
    12/14/2000 4:00 AM
    6:00
    4
    8/3/2000 3:10 PM
    8/3/2000 3:10 PM
    0:00
    5
    8/9/2000 3:05 PM
    8/9/2000 3:05 PM
    0:00
    6
    8/9/2000 5:15 PM
    8/9/2000 5:15 PM
    0:00
    7
    1/21/2000 6:00 AM
    1/22/2000 4:00 AM
    20:00
    8
    1/21/2000 6:00 AM
    1/22/2000 4:00 AM
    20:00
    9
    1/16/2000 9:00 AM
    1/17/2000 7:00 AM
    22:00
    10
    1/16/2000 9:00 AM
    1/17/2000 7:00 AM
    22:00
    11
    1/17/2000 3:00 AM
    1/18/2000 12:00 PM
    4:00
    12
    1/17/2000 3:00 AM
    1/18/2000 12:00 PM
    4:00
    Dave

  3. #3
    Registered User
    Join Date
    09-17-2016
    Location
    ny,ny
    MS-Off Ver
    2013
    Posts
    7

    Re: Check if event occurs within time range

    Hi FlamingRetired,

    Thanks for the quick response! That formula is helpful to see the time in between the start and end date but doesn't accomplish the goal.

    To clarify, if there is any overlap between the start and end hours that fall between 8:00PM and 8:00AM, I would like the formula to return "TRUE", if not then "FALSE." As an example, C2 should be True because the event ended at 8AM, which would fall in the range of 8PM-8AM. C4 should return False, no period between the start and end fall between the required time frame.

    The end goal is that I want to know if an event occurs between 8PM and 8AM given the start and end periods. In some cases the difference between the start and end date can be over 24 hours, those should always return "TRUE"

    Thanks again!

  4. #4
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Check if event occurs within time range

    Withdrawn by FR.
    Last edited by FlameRetired; 09-18-2016 at 12:27 AM.

  5. #5
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Check if event occurs within time range

    Sorry about that. There was a mistake in my previous (withdrawn) formula.

    With the decimal times for 8PM and 8AM in C1:D1 this formula in C2 filled down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Row\Col
    A
    B
    C
    D
    1
    est begin time est end time
    0.833333
    0.333333
    2
    12/31/2000 7:00 AM
    12/31/2000 8:00 AM
    TRUE
    3
    12/13/2000 10:00 PM
    12/14/2000 4:00 AM
    TRUE
    4
    8/3/2000 3:10 PM
    8/3/2000 3:10 PM
    FALSE
    5
    8/9/2000 3:05 PM
    8/9/2000 3:05 PM
    FALSE
    6
    8/9/2000 5:15 PM
    8/9/2000 5:15 PM
    FALSE
    7
    1/21/2000 6:00 AM
    1/22/2000 4:00 AM
    TRUE
    8
    1/21/2000 6:00 AM
    1/22/2000 4:00 AM
    TRUE
    9
    1/16/2000 9:00 AM
    1/17/2000 7:00 AM
    TRUE
    10
    1/16/2000 9:00 AM
    1/17/2000 7:00 AM
    TRUE
    11
    1/17/2000 3:00 AM
    1/18/2000 12:00 PM
    TRUE
    12
    1/17/2000 3:00 AM
    1/18/2000 12:00 PM
    TRUE

  6. #6
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Check if event occurs within time range

    This would be a shorter formula with the same set-up helper row.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  7. #7
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Check if event occurs within time range

    Another withdrawn.
    Last edited by FlameRetired; 09-18-2016 at 04:09 AM.

  8. #8
    Registered User
    Join Date
    09-17-2016
    Location
    ny,ny
    MS-Off Ver
    2013
    Posts
    7

    Re: Check if event occurs within time range

    Thank you so much. Those mostly work though I did find that the second formula using MMULT is more accurate. There was a case where the the end time was 8PM and both formulas returned false thought it should be true since it ends at 8PM and that would be within the range- the start and end times respectively were 1/13/2000 12:00 1/13/2000 20:00

    really appreciate the help, I've been spending days on this and couldn't get as far as you! If you don't mind how does that second formula work? I looked up the functions but not sure how they work together.
    Last edited by excellinginlife; 09-19-2016 at 12:15 PM.

  9. #9
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Check if event occurs within time range

    Yes.

    Still needs work.
    Last edited by FlameRetired; 09-19-2016 at 12:47 PM.

  10. #10
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Check if event occurs within time range

    This seems to cover everything.

    In addition to the same helper row two helper columns. This helper formula in C2:D15.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Then this formula in E2 filled down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Row\Col
    A
    B
    C
    D
    E
    1
    est begin time est end time
    8:00:00 PM
    8:00:00 AM
    2
    12/31/2000 7:00 AM
    12/31/2000 8:00 AM
    12/31/2000 8:00 PM
    12/31/2000 8:00 AM
    TRUE
    3
    12/13/2000 10:00 PM
    12/14/2000 4:00 AM
    12/13/2000 8:00 PM
    12/14/2000 8:00 AM
    TRUE
    4
    8/3/2000 3:10 PM
    8/3/2000 3:10 PM
    8/3/2000 8:00 PM
    8/3/2000 8:00 AM
    FALSE
    5
    8/9/2000 3:05 PM
    8/9/2000 3:05 PM
    8/9/2000 8:00 PM
    8/9/2000 8:00 AM
    FALSE
    6
    8/9/2000 5:15 PM
    8/9/2000 5:15 PM
    8/9/2000 8:00 PM
    8/9/2000 8:00 AM
    FALSE
    7
    1/21/2000 6:00 AM
    1/22/2000 4:00 AM
    1/21/2000 8:00 PM
    1/22/2000 8:00 AM
    TRUE
    8
    1/21/2000 6:00 AM
    1/22/2000 4:00 AM
    1/21/2000 8:00 PM
    1/22/2000 8:00 AM
    TRUE
    9
    1/16/2000 9:00 AM
    1/17/2000 7:00 AM
    1/16/2000 8:00 PM
    1/17/2000 8:00 AM
    TRUE
    10
    1/16/2000 9:00 AM
    1/17/2000 7:00 AM
    1/16/2000 8:00 PM
    1/17/2000 8:00 AM
    TRUE
    11
    1/17/2000 3:00 AM
    1/18/2000 12:00 PM
    1/17/2000 8:00 PM
    1/18/2000 8:00 AM
    TRUE
    12
    1/17/2000 3:00 AM
    1/18/2000 12:00 PM
    1/17/2000 8:00 PM
    1/18/2000 8:00 AM
    TRUE
    13
    9/17/2016 6:00 PM
    9/17/2016 7:00 PM
    9/17/2016 8:00 PM
    9/17/2016 8:00 AM
    FALSE
    14
    9/17/2016 9:00 AM
    9/17/2016 10:00 AM
    9/17/2016 8:00 PM
    9/17/2016 8:00 AM
    FALSE
    15
    1/13/2000 12:00 PM
    1/13/2000 8:00 PM
    1/13/2000 8:00 PM
    1/13/2000 8:00 AM
    TRUE

  11. #11
    Registered User
    Join Date
    09-17-2016
    Location
    ny,ny
    MS-Off Ver
    2013
    Posts
    7

    Re: Check if event occurs within time range

    Hm, the new formula seems to show some which should be True as false when the start and end times are after 8PM and end before midnight. I've attached a larger sample set which shows some of these highlighted.

    2/13/2000 23:10 2/13/2000 23:10
    2/13/2000 23:15 2/13/2000 23:15
    1/16/2000 21:00 1/16/2000 23:00
    1/16/2000 21:00 1/16/2000 23:00
    Attached Files Attached Files

  12. #12
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Check if event occurs within time range

    Yes.

    There are two approaches in the attached.

    The first creates 3 more helper columns that parse the array in the previous formula into columns E:G. Entered in E2 filled down and across:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    The final formula in H2 filled down is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.



    On the other hand if you prefer to skip the additional helper columns (though they can be hidden for aesthetic purposes) this mega formula in I2 filled down does the job:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    While I didn't check every row I did a fairly thorough filtering check. It works on everything I've seen so far.

    I must say this one turns out to be more challenging than it first appeared.

    See what you think.

  13. #13
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Check if event occurs within time range

    excellinginlife,

    In rep PM you indicated that it's almost perfect.

    Does it need some more work?

  14. #14
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,913

    Re: Check if event occurs within time range

    Another way ...

    =OR(MOD(A2,1)>20/24,MOD(B2,1)>20/24,MOD(A2,1)<8/24,MOD(B2,1)<8/24,INT(A2)<>INT(B2))

  15. #15
    Registered User
    Join Date
    09-17-2016
    Location
    ny,ny
    MS-Off Ver
    2013
    Posts
    7

    Re: Check if event occurs within time range

    OOps sorry I forgot to send the reply. Still found a couple which returned FALSE even though it should be true. Thanks again. Something im trying instead is filtering to include anything with a time span over 12 hrs= true. And anything with start and end time between 8:01AM to 7:59PM is false.

    1/3/2000 20:00 1/3/2000 20:00
    6/18/2000 20:00 6/18/2000 20:30

  16. #16
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Check if event occurs within time range

    Looks like Phuocam nailed it.

    Also I kept assuming same time / same dates would be FALSE since there is zero time range for events to occur.

  17. #17
    Registered User
    Join Date
    09-17-2016
    Location
    ny,ny
    MS-Off Ver
    2013
    Posts
    7

    Re: Check if event occurs within time range

    Thank you both. That last formula looks like what I need!

  18. #18
    Registered User
    Join Date
    09-17-2016
    Location
    ny,ny
    MS-Off Ver
    2013
    Posts
    7

    Re: Check if event occurs within time range

    Yes the data shouldn't show like that but even with no time for the event to occur the formula should return true if it hits on 8:00 AM / 8:00PM. So the last formula actually doesn't work :/ Examples like
    3/22/2000 8:00 3/22/2000 12:00
    3/21/2000 8:00 3/21/2000 16:00
    should return true.

+ 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. FREQUENCY - Trying to check how many time an item occurs
    By yousuf0203 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-05-2014, 10:05 AM
  2. check if value occurs within a range
    By peacelittleone in forum Excel Formulas & Functions
    Replies: 37
    Last Post: 09-06-2005, 12:05 PM
  3. How do I have a formula check if a value occurs within a range?
    By afgncaap in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2005, 02:05 AM
  4. How do I have a formula check if a value occurs within a range?
    By afgncaap in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2005, 01:05 AM
  5. How do I have a formula check if a value occurs within a range?
    By afgncaap in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2005, 12:05 AM
  6. How do I have a formula check if a value occurs within a range?
    By afgncaap in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-05-2005, 11:05 PM
  7. How do I have a formula check if a value occurs within a range?
    By afgncaap in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-05-2005, 10:05 PM
  8. How do I have a formula check if a value occurs within a range?
    By afgncaap in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-01-2005, 02:05 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