+ Reply to Thread
Results 1 to 10 of 10

Need help finding nearest date from list of dates

  1. #1
    Registered User
    Join Date
    10-19-2017
    Location
    chicago
    MS-Off Ver
    excel2016
    Posts
    4

    Need help finding nearest date from list of dates

    I need a some help with a formula that takes the date from column A looks at all the dates in column B and spits out the nearest date from Column B into Column C. I have been using this formula =INDEX($B$1:$B$12,MATCH(A1+1,$B$1:$B$12,1)) and it will not always give me the nearest date.






    Column A Column B
    10/23/2017 10/25/2017
    10/24/2017 10/27/2017
    10/25/2017 11/3/2017
    10/27/2017 11/10/2017
    10/30/2017 11/14/2017
    10/31/2017 11/20/2017
    11/1/2017 11/24/2017
    11/2/2017 11/28/2017
    11/3/2017 12/05/2017
    11/6/2017 12/11/2017
    11/7/2017 12/22/2017
    11/7/2017
    11/8/2017
    11/9/2017
    11/14/2017
    11/15/2017
    11/16/2017
    11/20/2017
    11/21/2017
    11/22/2017
    11/23/2017
    11/24/2017
    11/27/2017
    11/28/2017
    11/29/2017
    11/30/2017
    12/1/2017
    12/4/2017
    12/5/2017
    12/6/2017
    12/7/2017
    12/8/2017
    12/12/2017
    12/13/2017
    12/14/2017
    12/18/2017
    12/20/2017
    12/21/2017
    12/22/2017

  2. #2
    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,640

    Re: Need help finding nearest date from list of dates

    What do you mean? Perhaps you could be more explicit about when it fails?

    Welcome, by the way!
    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.

  3. #3
    Registered User
    Join Date
    10-19-2017
    Location
    chicago
    MS-Off Ver
    excel2016
    Posts
    4

    Re: Need help finding nearest date from list of dates

    The formula fails sense that it always produces the date that is before it unless that date is one day after and picks up the +1 in the formula.

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: Need help finding nearest date from list of dates

    How do you intend to sort out "nearest date" for say 11/22/17 which is two days from 11/20/17 and 11/24/17?

    I would probably change the lookup table so that it gives the correct result. Assuming something like 11/22/17 can be matched with 11/24/17, I might add a helper column =AVERAGE(B2:B3) in E3 [note relative reference for a moving average], then copy down to get the midpoints of the list of dates in column B. I would probably put an earliest data (10/1/17???) into E2 to avoid the N/A errors that the earlier dates will give. Then use that as the lookup column for the MATCH() function MATCH(A2,$E$2:$E$12,1)
    Last edited by MrShorty; 10-23-2017 at 12:02 PM.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

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

    Re: Need help finding nearest date from list of dates

    I moved column B to column D for clarity.

    If by "nearest" you mean past, present, or future, try this in B2:

    =INDEX(D$2:D$12,MATCH(MIN(ABS(D$2:D$12-A2)),ABS(D$2:D$12-A2),0)) Ctrl Shift Enter

    See attachment for clarification.

    Edit: MrShorty brings up a good point about dates that are the same distance away (future and past). I did not consider that.
    Attached Files Attached Files
    Last edited by 63falcondude; 10-23-2017 at 12:03 PM.

  6. #6
    Registered User
    Join Date
    10-19-2017
    Location
    chicago
    MS-Off Ver
    excel2016
    Posts
    4

    Re: Need help finding nearest date from list of dates

    The issue I have is that i need column C to read an exact date from column B, the formula still points to the earlier date in column B

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

    Re: Need help finding nearest date from list of dates

    Hello Pcec21,

    I just read this thread for the first time and I don’t think you’ve really explained what you want to do. Can you give some concrete examples? For example, given the data in post 1 what result do you expect to get in C1, C2, C3 etc?
    Audere est facere

  8. #8
    Registered User
    Join Date
    10-19-2017
    Location
    chicago
    MS-Off Ver
    excel2016
    Posts
    4

    Re: Need help finding nearest date from list of dates

    Sorry I had to step away from my desk for a moment. The formula that 63falcondude gave worked perfectly! I am very new to this and I greatly appreciate all the help.

  9. #9
    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,640

    Re: Need help finding nearest date from list of dates

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

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

    Re: Need help finding nearest date from list of dates

    Great, glad we could help.

+ 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. [SOLVED] Finding the nearest location from list of latitude Longitude
    By spike4848 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-16-2019, 11:45 PM
  2. Finding Nearest date in a range based on critera date
    By skate1991 in forum Excel General
    Replies: 5
    Last Post: 07-22-2015, 02:10 PM
  3. Finding the weekending date from a list of given dates
    By echolakemt in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-11-2014, 11:08 PM
  4. Finding the nearest date in a column with reference to today
    By lenare in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-24-2013, 10:51 AM
  5. finding the latest date in a list of dates
    By easty in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 01-14-2010, 01:34 AM
  6. Finding the closest future date from Today from a list of dates
    By maharg in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-18-2008, 09:45 AM
  7. [SOLVED] How do I select the nearest date from a ranges of dates?
    By gerrit in forum Excel General
    Replies: 3
    Last Post: 02-12-2006, 12: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