troubleshooting Question

Join 2 Tables using datetime fields that are not exact matches

Avatar of Ed_Snowden
Ed_Snowden asked on
Microsoft SQL ServerMicrosoft SQL Server 2005Microsoft SQL Server 2008SSRS
2 Comments1 Solution379 ViewsLast Modified:
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.
SELECT     *
FROM         PhoneBill LEFT OUTER JOIN
                      PBXDATA ON PhoneBill.[Call Time] = PBXDATA.CALL_TIME AND PhoneBill.Duration = PBXDATA.DURATION
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros