I have 2 tables with a field datetime2
each. Nanoseconds are also stored in one of the tables, and only milliseconds in the other (this data cannot be changed). Now I want to compare 2 tables and check if the values match datetime2
, but I have to ignore nanoseconds for this.
Sample data:
Table1 Table2
2018-01-24 10:51:23.9976180 2018-01-24 10:51:23.9970000
2018-01-24 10:51:23.9976180 2018-01-24 10:51:23.9970000
2018-01-24 11:08:23.2578500 2018-01-24 11:08:23.2570000
Currently my request is as follows:
select t1.* from Table1 t1, Table12 t2 where t1.tradeDateTime = t2.tradeDate
As you can guess, I am not getting any results for this example, because the nanoseconds are different from each other.
So my question is: how can I ignore nanoseconds in where
-clause?
Edit:
I know that I must use the correct JOIN
s. This request was just verified if I made no errors in my request usingJOIN