I am trying to do a
LEFT JOIN on two tables, where one table has a datetime column, and the other table has a date column. As I am working in SQL Server, I used
CONVERT to change the datetime to date. I then wrote the join statement:
SELECT CONVERT(date,db1.dbo.table1.datecolumn), db2.dbo.table2.datecolumn FROM db1.dbo.table1 LEFT JOIN db2.dbo.table2 ON db1.dbo.table1.datecolumn = db2.dbo.table2.datecolumn
And the query returns the date column from table1, but the column from table2 is populated with NULL values only. I am not sure what I am doing wrong. I tried
CAST instead of
CONVERT, with no luck. Is there something happening with the conversion? Any help is appreciated.