Hi all,
I have two datetime tables say A and B. I am able to compare A to B and extract the datetimes in A nearest to B with no repetitions. That’s no datetime in A can be selected twice.
Now I want to compare A to B and instead of the nearest in A to B, I want to select or find the second nearest or highest datetime. For example, given the following datetimes, A = 2/1/2016 11:42, 2/1/2016 11:44 and B = 2/1/2016 11:43. The closest datetime comparing A to 2/1/2016 11:43 in B is 2/1/2016 11:42. Now what if I want to select the second highest or second closest/nearest datetime to 2/1/2016 11:43? In this case it will be 2/1/2016 11:44. I want to do this in a loop since A and B contains multiple datetimes. Compare A to B and select the indexes of all second nearest/highest/closest datetime in A to B. And then I will use the indexes to extract row data from another table. I am still learning and I appreciate your help. Thanks!
Best Answer