In my table, I have a datetime NULL field called logDate. The format stored: 2014-03-28 12:24:00.000
I have a form and the log date is one of the fields for searching logs. The user will enter the date like 2014-03-28
So in my SELECT procedure I need to use a LIKE:
@logDate datetime =NULL
.
.
SELECT .. FROM mytable WHERE
(@logDate IS NULL OR CONVERT(VARCHAR, @logDate, 102) LIKE '%'+logDate+'%')
I execute the procedure:
EXEC dbo.SELECT_mytable @logDate= '2014-03-28'
But I get the following error:
Conversion failed when converting date and/or time from character string.
What am I doing wrong?