I have used a convert function in one of my Queries
Select * from tblMas where FromDate >= CONVERT(varchar(10), @FromDate,112)
@FromDate is a Datetime parameter, I don’t know why but this query works fine.
Though it should not as FromDate is of DateTime field and we are comparing it with Varchar field.
CONVERT(varchar(10), @FromDate, 112) returns result in yyyyMMdd format. I am lost how SQL Server is comparing this and returning right result.
There will be an implicit type conversion from varchar to datetime before the comparison.
If you have a look at the queryplan you will see something like this.
Another way to remove the time part from a datetime.
In SQL Server 2008 you can use