In one of my table, we import data exported from two different sources.so the date column has two formats one is 'dd/mm/yyy' and the other one is 'yyyymmdd' in the same column and the data type is varchar(50).Now when I write a query like this, it doesn't include data with 'yyyymmdd' format.select convert(varchar(8),convert(datetime,date,103),112) as Date,sum(qty1), sum(qty2), sum(qty3) from table1where convert(varchar(8),convert(datetime,date,103),112) = '20120701'
As you see in my code, i want to display it in format 'yyyymmdd' and even in where conditions i want it to be 'yyyymmdd'.