Programmers learn & share
0 votes

Problem :

I was getting the following error when running a SQL
the conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
by (6.9k points)   | 22 views

1 Answer

0 votes

Solution :

I had this issue due to a silly mistake. 

For e.g.:

September 31, 2015 non existing date.

EXEC dbo.SearchByDateRange @Start = '20150901' , @End = '20150931'

So this fails and will give error message:

Error converting data type varchar to datetime.

To fix it just input a valid date:

EXEC dbo.SearchByDateRange @Start = '20150901' , @End = '20150930'

It will executes just fine and your issue will be fixed .

by (36.1k points)  
2,218 questions
2,683 answers
241 users