When I run this code in SQL-Server 2008,
select case when '6/1/2012' < '6/1/2012' then 1 else 0 end
I get 0.
And if I run,
select case when '6/1/2012 0:00:00.000' < '6/1/2012' then 1 else 0 end
I also get 0.
BUT, if I run
select case when '6/1/2012' < '6/1/2012 0:00:00.000' then 1 else 0 end
I get 1.
Why is this?
My guess is:
You may be expecting your database to automatically detect dates, but that would involve parsing every string you give it in case it’s a date, which would hurt performance and could also be confusing (if something gets converted to a date and you didn’t mean for it to be).