+ Reply to Thread
Results 1 to 11 of 11

Find the nearest date in a range of dates formula

  1. #1
    Registered User
    Join Date
    10-20-2017
    Location
    California
    MS-Off Ver
    Windows 10
    Posts
    7

    Find the nearest date in a range of dates formula

    Hi,

    Was hoping someone could help me with a formula that returns the nearest date in a range of dates, where the returned date is earlier than the search date.

    This is what I have: =INDEX(B:B,MATCH(MIN(IF(C:C=L2,abs(B:B-K2))),ABS(B:B-K2),0)), however, this returns the nearest date later than the search date.

    Thank you,
    Caroline

  2. #2
    Registered User
    Join Date
    10-20-2017
    Location
    California
    MS-Off Ver
    Windows 10
    Posts
    7

    Re: Find the nearest date in a range of dates formula

    For context, this is an example:

    A B C D E
    Date Object Search date Object Returned date
    06/05/2007 a 06/14/2007 a 06/16/2007
    10/10/2007 b
    06/16/2007 a
    03/04/2007 b


    =INDEX(A:A,MATCH(MIN(IF(B:B=D3,abs(A:A-C3))),ABS(A:A-C3),0))
    Returns 06/16/2007

  3. #3
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Find the nearest date in a range of dates formula

    Based on your example from post #2, in E2, try this:

    =MAX(IF((A$2:A$5<=C2)*(B$2:B$5=D2),A$2:A$5)) Ctrl Shift Enter
    Last edited by 63falcondude; 10-20-2017 at 02:30 PM. Reason: Typo

  4. #4
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: Find the nearest date in a range of dates formula

    It would be best if you could post a sanitized sample of your data and criteria. It looks like you have other criteria based on your formula which isnt explained in your post and your example makes it extremely difficult to be sure of what data is reference by your formula.

    If the Date was the only criteria then a MAX/IF array formula would it. I have a feeling you have other criteria though.

  5. #5
    Registered User
    Join Date
    10-20-2017
    Location
    California
    MS-Off Ver
    Windows 10
    Posts
    7

    Re: Find the nearest date in a range of dates formula

    Date___________Object_______Search date______Object______Returned date
    03/03/2007_______a_________06/14/2007_________a________06/16/2007
    06/05/2007_______a
    06/16/2007_______a
    09/09/2007_______a
    10/10/2007_______b
    03/04/2007_______b


    Best attempt at creating a table.

    Criteria is to return nearest date to search date for object a,for which the returned date precedes search date.

    I'm using argument: =INDEX(A:A,MATCH(MIN(IF(B:B=D3,abs(A:A-C3))),ABS(A:A-C3),0)) and it is producing a returned date of 6/16/2007, when I'd like it to produce 6/5/2007.
    Last edited by kaytoc; 10-20-2017 at 03:09 PM.

  6. #6
    Registered User
    Join Date
    10-20-2017
    Location
    California
    MS-Off Ver
    Windows 10
    Posts
    7

    Re: Find the nearest date in a range of dates formula

    Thank you 63falondude. The formula returns a value however it is not the nearest value.
    Thank you Zer0Cool. I'm new to this forum. Working on figuring out how to post data.

  7. #7
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Find the nearest date in a range of dates formula

    I'm not sure where you're going wrong. I have attached a workbook showing the formula in action.

    For display purposes, I have put a column in between Object and Search date.

    Also, it would help much more if you share what the expected result is not the wrong result.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    10-20-2017
    Location
    California
    MS-Off Ver
    Windows 10
    Posts
    7

    Re: Find the nearest date in a range of dates formula

    Thank you 63falcondude. I cannot open your file. I believe it's because I am using google sheets.
    The expected result, is 06/05/2007

  9. #9
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Find the nearest date in a range of dates formula

    That would have been helpful to know from the start... This is an Excel forum, not a Google Sheets forum.

    Although the two may seem similar to you, they are quite different.

    That being said, we do have a section for other platforms here:
    https://www.excelforum.com/for-other...mobile-os-etc/

  10. #10
    Registered User
    Join Date
    10-20-2017
    Location
    California
    MS-Off Ver
    Windows 10
    Posts
    7

    Re: Find the nearest date in a range of dates formula

    Oversight on my part. Still getting familiar with what's what. Thank you for the link. I appreciate your time.

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,458

    Re: Find the nearest date in a range of dates formula

    Thread moved to other platforms section.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

+ 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. To compare & find out the nearest date in the range with a common date
    By rkulasekaran in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-04-2015, 08:08 AM
  2. [SOLVED] Find the Exact date, Nearest old and new date for the given input Letter) and date
    By thilag in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-17-2015, 05:13 AM
  3. Replies: 1
    Last Post: 11-25-2014, 07:26 PM
  4. Replies: 0
    Last Post: 05-30-2013, 07:50 PM
  5. Replies: 1
    Last Post: 04-04-2012, 08:21 AM
  6. Replies: 4
    Last Post: 08-23-2011, 07:42 AM
  7. Replies: 8
    Last Post: 02-27-2009, 06:06 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