Join 2 Tables using datetime fields that are not exact matches
I need to join 2 tables using datetime fields. Most of the corresponding entries in each table have the exact datetime down to the exact seconds. But some are up between 3 and 50 seconds different.
How can I add a tolerance so that the records join in the 2 tables.
Below is the SQL I'l using at the moment. On the first join I need a tolerance of 50 seconds and on the 2nd join I need a tolerance of 5 seconds.
FROM PhoneBill LEFT OUTER JOIN
PBXDATA ON PhoneBill.[Call Time] = PBXDATA.CALL_TIME AND PhoneBill.Duration = PBXDATA.DURATION
Microsoft SQL Server 2008SSRSMicrosoft SQL ServerMicrosoft SQL Server 2005