Use DateDiff function to match two columns

71 Views Asked by At

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.

1

There are 1 best solutions below

1
On

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