• Register
0 votes
25 views

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.
6.9k points

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 .

36.1k points

Related questions

0 votes
1 answer 43 views
43 views
Problem : I am getting bellow error related to datetime the conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.
asked Nov 7, 2019 peterlaw 6.9k points
0 votes
1 answer 181 views
181 views
Problem : I have the table storing starttime and endtime. I am facing below error: “Conversion failed when converting character string to smalldatetime data type.” While selecting the below query using that table. select CAST(substring(CONVERT(varchar,convert(smalldatetime,o. ... face any error. But, when I select it from a table I got the error. Can somebody help me with this?
asked Jan 20 jwilliam 3.9k points
1 vote
1 answer 16 views
16 views
Problem : I am new to SQL. While trying to execute my JOIN query I am facing below strange error. “Conversion failed when converting the varchar value to data type int”. I am unable to figure out why am I getting above error. Can someone help me in fixing the error?
asked Mar 27 morrisBson 3.2k points
1 vote
1 answer 23 views
23 views
Problem : I am very new to SQL. If I try to use the sp_executesq I am often facing below strange looking error: “Procedure expects parameter '@statement' of type 'ntext/nchar/nvarchar'.” I have spent more than two days on above error but still can not fix above sql related error. Please guide me in fixing above sql error.
asked May 12 Martin K 6.6k points
0 votes
1 answer 121 views
121 views
Problem : My stored procedure giving me following error cannot perform an aggregate function on an expression containing an aggregate or a subquery.
asked Nov 15, 2019 peterlaw 6.9k points