+ Reply to Thread
Results 1 to 11 of 11

If date between any of multiple date ranges

  1. #1
    Registered User
    Join Date
    02-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    5

    If date between any of multiple date ranges

    Hi,

    I would be sooooo grateful for anyone's help. I am trying to solve a problem with patient flow through operating theatres. What I need to be able to do is:

    StartDateAndTime1 EndDateAndTime1
    StartDateAndTime2 EndDateAndTime2
    ...
    StartDateAndTimeN EndDateAndTimeN

    If ThisDateAndTime is between any of the pairs of StartDateAndTime and EndDateAndTime then value of cell is 1

    Can anyone help? Thank you very much.

    Mark.

  2. #2
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: If date between any of multiple date ranges

    attach excel file with some dummy data and result what you required

  3. #3
    Registered User
    Join Date
    10-05-2012
    Location
    Mumbai
    MS-Off Ver
    Excel 2010
    Posts
    30

    Re: If date between any of multiple date ranges

    Use IF Function

  4. #4
    Registered User
    Join Date
    02-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: If date between any of multiple date ranges

    Hi,

    Thank you for taking an interest. Is this adequate?

    BW

    Mark.
    Attached Files Attached Files

  5. #5
    Forum Expert Kevin UK's Avatar
    Join Date
    12-07-2010
    Location
    Radstock, Somerset
    MS-Off Ver
    365
    Posts
    1,922

    Re: If date between any of multiple date ranges

    Hi paperworkmonkey

    Assuming in- A1: Date1/Time B1: Date/Time

    Date/Time you want to check is in A3
    =IF(AND(A3>=A1,A3<=B1),1,"")
    Regards Kevin


    Merged Cells (They are the work of the devil!!!)

  6. #6
    Registered User
    Join Date
    02-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: If date between any of multiple date ranges

    Hi pakhare.kiran

    I would but there are _thousands_ of start and finish times...

    Mark

  7. #7
    Registered User
    Join Date
    02-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: If date between any of multiple date ranges

    Quote Originally Posted by Kevin UK View Post
    Hi paperworkmonkey

    Assuming in- A1: Date1/Time B1: Date/Time

    Date/Time you want to check is in A3
    =IF(AND(A3>=A1,A3<=B1),1,"")
    Hi Kevin,

    That would work for one date range, but I need to see if A3 is between any of A1 and B1, A2 and B2, A3 and B3 all the way to A1000 and B1000. I'm not sure how to search in thousands of pairs.

    BW

    Mark

    P.S. - oops sorry, that should read "...but I need to see if D3 is between any of A1 and B1, A2 and B2, A3 and B3 all the way to A1000 and B1000. I'm not sure how to search in thousands of pairs."
    Last edited by paperworkmonkey; 02-20-2013 at 06:32 AM.

  8. #8
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: If date between any of multiple date ranges

    Use this formula in E1 Cell in your patientflowexample workbook

    =SUMPRODUCT(($D1>=TEXT($A$2:$A$7,"HH:MM")*1)*($D1<=TEXT($B$2:$B$7,"HH:MM")*1))

  9. #9
    Registered User
    Join Date
    02-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: If date between any of multiple date ranges

    Quote Originally Posted by nflsales View Post
    Use this formula in E1 Cell in your patientflowexample workbook

    =SUMPRODUCT(($D1>=TEXT($A$2:$A$7,"HH:MM")*1)*($D1<=TEXT($B$2:$B$7,"HH:MM")*1))

    You are a flippin' genius! Thank you thank you thank you! I've not got the first clue how that works at the moment but I will spend a good while making sure I do understand it eventually. Thanks a million, you've made my life much easier.

    Best wishes,

    Mark.

  10. #10
    Registered User
    Join Date
    11-02-2015
    Location
    USA
    MS-Off Ver
    Mac 2011
    Posts
    8

    Re: If date between any of multiple date ranges

    Quote Originally Posted by nflsales View Post
    Use this formula in E1 Cell in your patientflowexample workbook

    =SUMPRODUCT(($D1>=TEXT($A$2:$A$7,"HH:MM")*1)*($D1<=TEXT($B$2:$B$7,"HH:MM")*1))

    Hi nflsales. I have a follow-up question to this fantastic solution. How would you adjust the formula if the values in Col D were also in a date & time format (e.g., 4/3/2017 10:15:11 AM) instead of just in a HH:MM format?
    Thank you!

  11. #11
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: If date between any of multiple date ranges

    Moveit, welcome to the forum

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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