Distance of date from closest date in a list

gero92

New Member
Joined
Apr 15, 2018
Messages
10
Hello everybody,

I am trying to find a solution to a problem it's causing me many difficulties. I have a list of 7-8 dates of events, and a list of the days for the next 2 years. See the below example:

LIST OF EVENTS
18/04/2018
18/05/2018
20/08/2018
....
....
10/08/2019

CALENDAR
=today()
+1
+1
...
..
..
01/01/2020

I want to find for each day of the calendar the distance from the closest date in the EVENT list. For example today's date is the 15/04/2018, the closest date from the EVENT list is the 18/04/2018, so I want the formula to return the value 3. If I am looking at the 20/04/2018, I want the value -2 as it is 2 days after the closest date. If I am looking at the 22/05/2018 I want the formula to return -4 as it is 4 days after the closest date in the EVENT list 20/08/2019.

I tried many solutions from the forum but they don't really work on this case. I would be so grateful if somebody could help!:)

Thank you so much in advance.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hi!

Try the Array Formula below in D2 and copy down

Use Ctrl+Shift+Enter to enter the formula

=INDEX(A$2:A$8,MATCH(MIN(ABS(A$2:A$8-C2)),ABS(A$2:A$8-C2),0))-C2


ABCDE
1LIST OF EVENTSCALENDARRESULT
218/04/201815/04/20183
318/05/201816/04/20182
420/08/201817/04/20181
522/11/201818/04/20180
624/02/201919/04/2018-1
729/05/201920/04/2018-2
810/08/201921/04/2018-3
922/04/2018-4
3114/05/20184
3215/05/20183
3316/05/20182
3417/05/20181
3518/05/20180
3619/05/2018-1
3720/05/2018-2
3821/05/2018-3
3922/05/2018-4
4023/05/2018-5
12516/08/20184
12617/08/20183
12718/08/20182
12819/08/20181
12920/08/20180
13021/08/2018-1
13122/08/2018-2
13223/08/2018-3
13324/08/2018-4
*****************************************

<tbody>
</tbody>


Markmzz
 
Upvote 0
In E1 ontrol+shift+enter, not just enter:

=INDEX($A$1:$A$8,MATCH(MIN(ABS($A$1:$A$8-D1)),ABS($A$1:$A$8-D1),0))-D1

where D1 houses a date like 2018-04-15 (today's date) and A1:A8 an event list of dates.
 
Upvote 0
Hi!

Try the Array Formula below in D2 and copy down

Use Ctrl+Shift+Enter to enter the formula

=INDEX(A$2:A$8,MATCH(MIN(ABS(A$2:A$8-C2)),ABS(A$2:A$8-C2),0))-C2

Markmzz

One more option (a smalll modification in my first formula) in D2 and copy down:

Use only Enter to enter the formula

=INDEX(A$2:A$8,MATCH(MIN(INDEX(ABS(A$2:A$8-C2),)),INDEX(ABS(A$2:A$8-C2),),0))-C2

Markmzz
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,471
Messages
6,125,000
Members
449,202
Latest member
Pertotal

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top