June 18, 2010 at 7:46 pm
I am unable to retrieve data based on the where clause which refers to the date(stored in a varchar) column.
SELECT count(*)
FROM table1 where colls like '%ABC%'
and table1.unit=@unit
and
date
between
@startdate
and
@enddate
GO
It reurns 0 rows.
Thanks
June 18, 2010 at 7:55 pm
Which is why you should store dates in a datetime column.
try "and convert(datetime, date) between" ...
of course, this will completely prevent the use of any supporting indexes on that field.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply