user2908171
user2908171

Reputation:

Use DateDiff function to match two columns

I have the following check:

'20'+convert(char,tc.TransactionDateStamp,12) = pr.DateOut
AND substring(tc.TransactionTimeStamp,1,2) + substring(tc.TransactionTimeStamp,4,2) + substring(tc.TransactionTimeStamp,7,2) = pr.TimeOut

This works, but if the time in tc.TransactionTimeStamp is different to pr.TimeOut by like five seconds then it doesnt match. I need to put in a check which will allow these two to match even if the time is diff by 30 seconds.

Upvotes: 1

Views: 60

Answers (1)

Madhivanan
Madhivanan

Reputation: 13700

Is this?

'20'+convert(char,tc.TransactionDateStamp,12) = pr.DateOut 
AND substring(tc.TransactionTimeStamp,1,2)+substring
(tc.TransactionTimeStamp,4,2)+substring
(tc.TransactionTimeStamp,7,2) between pr.TimeOut and pr.TimeOut+30

Upvotes: 1

Related Questions