Hi I have two tables which I have to join on ID field and then on closest date ( only if the date is within one hour range more or less), the reason is both tables are not updated at same time so time is little off between the two ( but max delay is 1 hr). Please see below example:
Table 1:
ID Start_Date End_Date
1 1/14/2021 14:34 1/27/2021 10:31
1 2/4/2021 10:40 7/2/2021 13:01
2 8/2/2020 00:04 9/7/2020 11:26
2 11/4/2020 9:24 2/8/2021 16:22
Table 2:
ID Start_date End_Date
1 1/14/2021 13:47 1/27/2021 10:24
2 8/1/2020 23:57 9/7/2020 11:22
2 11/4/2020 9:12 2/8/2021 16:20
In this example: record 1 from table 1 should join to record 1 from table2.
records 2 from table 1 should not join to table 2 ( since there is no record within 1 hr start date for that ID) record 3,4 should join to record 3,4 in table2 respectively.