Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to get Closest Date

Hi,

I have Table(Table1) and need to get the column "State" from Table 2. I want the state with the same Number and the closest Date2 from Date 1 but can't get it right.

Here's an example:

Table1:

Number     Date1

1               16/08/2016   

1               21/08/2016

1               26/08/2016

2               07/08/2016

2               16/08/2016

3               07/08/2016

3               12/08/2016

Table2:

Number     Date2             State

1              10/08/2016             A

1              14/08/2016             B

1              20/08/2016             D

1              28/08/2016             B

2              05/08/2016             C

2              10/08/2016             C

2              20/08/2016             B

3              04/08/2016             A

3              06/08/2016             A

3              14/08/2016             B

3              28/08/2016             C

Final Table:

Number     Date1           State

1               16/08/2016          B

1               21/08/2016          D

1               26/08/2016          B

2               07/08/2016          C

2               16/08/2016          B

3               07/08/2016          A

3               12/08/2016          B

Regards,

Francisco.

1 Solution

Accepted Solutions
antoniotiman
Master III
Master III

Hi Francisco,

see Attachment.

Regards,

Antonio

View solution in original post

3 Replies
sunny_talwar

See my response here:

How to get Closest Date

antoniotiman
Master III
Master III

Hi Francisco,

see Attachment.

Regards,

Antonio

Not applicable
Author

Thank you!