+ Reply to Thread
Results 1 to 9 of 9

If date falls between two dates using arrays

  1. #1
    Registered User
    Join Date
    10-26-2016
    Location
    Sterling, VA
    MS-Off Ver
    10
    Posts
    5

    If date falls between two dates using arrays

    I want to write a formula that tells me which contract month the cell falls in based on an array look up of start and end dates.

    My source data is a reference table with three columns. One for contract month, one for start date, and one for end date.

    Input: Date
    Output: Contract Month

    G2=9/16/2016
    A:A=Contract Month 1, 2, 3, 4....12
    B:B=Start Date
    C:C= End Date

    Example: =IF(AND(G2>=INDEX(A:A(MATCH(G2, B:B, 0), G2<=INDEX(A:A(MATCH(G2, C:C, 0)

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    MS 365 Business (Win 10 - Work) & MS 365 Subscription Insider (Win 10 - Home)
    Posts
    42,086

    Re: If date falls between two dates using arrays

    I think you might be overcomplicating this, but without some sample data and expected outcomes, it's hard to know for sure. Please provide some sample data for the three columns that reflect what is in your real file and your expected outcome.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!

    Forum Rules (updated September 2018): please read them here.
    How to use the Power Query code you've been given: help here. More about the Power suite here.
    Don't forget to say "thank you" to those who have helped you in your thread. If you wish, you can also reward them by clicking on their reputation star bottom left.

  3. #3
    Registered User
    Join Date
    10-26-2016
    Location
    Sterling, VA
    MS-Off Ver
    10
    Posts
    5

    Re: If date falls between two dates using arrays

    Contract Month Start Date End Date
    Contract-Month 1 8/5/2016 9/4/2016
    Contract-Month 2 9/5/2016 10/4/2016
    Contract-Month 3 10/5/2016 11/4/2016
    Contract-Month 4 11/5/2016 12/4/2016
    Contract-Month 5 12/5/2016 1/4/2017
    Contract-Month 6 1/5/2017 2/4/2017
    Contract-Month 7 2/5/2017 3/4/2017
    Contract-Month 8 3/5/2017 4/4/2017
    Contract-Month 9 4/5/2017 5/4/2017
    Contract-Month 10 5/5/2017 6/4/2017
    Contract-Month 11 6/5/2017 7/4/2017
    Contract-Month 12 7/5/2017 8/4/2017

    Timesheet Date
    9/16/2016
    9/17/2016
    9/18/2016

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    Waterlooville,England
    MS-Off Ver
    Office 2010
    Posts
    16,518

    Re: If date falls between two dates using arrays

    Try

    =INDEX($A$2:$A$13,MATCH(1,($B$2:$B$13<=$G2)*($C$2:$C$13>=$G2),0))

    Enter with Ctrl+Shift+Enter

    column F has your time sheet dates

  5. #5
    Registered User
    Join Date
    10-26-2016
    Location
    Sterling, VA
    MS-Off Ver
    10
    Posts
    5

    Re: If date falls between two dates using arrays

    It worked! Thank you!
    I was missing the 1 as the value in the MATCH formula, as well as the *. What functions do those serve?

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    Waterlooville,England
    MS-Off Ver
    Office 2010
    Posts
    16,518

    Re: If date falls between two dates using arrays

    The "1" is equivalent to TRUE and the "*" denotes an AND condition so we test if data is > Start Date AND < end date.

    FYI "+" is equivalent to "OR" condition.

  7. #7
    Registered User
    Join Date
    10-26-2016
    Location
    Sterling, VA
    MS-Off Ver
    10
    Posts
    5

    Re: If date falls between two dates using arrays

    Thank you so much!

  8. #8
    Registered User
    Join Date
    02-03-2020
    Location
    Philippines
    MS-Off Ver
    MS Office 2010
    Posts
    8

    Re: If date falls between two dates using arrays

    Quote Originally Posted by JohnTopley View Post
    Try

    =INDEX($A$2:$A$13,MATCH(1,($B$2:$B$13<=$G2)*($C$2:$C$13>=$G2),0))

    Enter with Ctrl+Shift+Enter

    column F has your time sheet dates
    would you be kind enough to include highlighting the equivalent cell if found, would that be possible?
    example in the given date:

    it should highlight cell A3
    Last edited by paniqui2020; 02-05-2020 at 09:26 PM.

  9. #9
    Forum Guru Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    Excel 2010 on Linux
    Posts
    11,460

    Re: If date falls between two dates using arrays

    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    Be very, very careful using IFERROR ! It hides ALL errors which is not always what you want to get correct results

+ 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. Sum if date falls between two dates
    By pauldaddyadams in forum Excel General
    Replies: 1
    Last Post: 09-10-2015, 02:07 PM
  2. HELP: Return a value with a date that falls between two other dates
    By hionman in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 11-18-2014, 08:01 AM
  3. Replies: 12
    Last Post: 06-13-2014, 05:03 PM
  4. [SOLVED] How to compute if a date falls between two specified dates??
    By Swagata in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-12-2012, 07:48 AM
  5. [SOLVED] Value with Corresponding Date if Falls Within Range of Dates
    By ebdmbfan in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-26-2012, 09:14 AM
  6. returning a value if a date falls between two dates
    By chillangella in forum Excel General
    Replies: 3
    Last Post: 09-28-2009, 06:51 AM
  7. How to find if a date falls between 2 dates
    By JHL in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-19-2005, 01:50 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