• Register
0 votes
47 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 5 3
6,930 points

Please log in or register to answer this question.

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 .

9 7 4
38,600 points

Related questions

0 votes
1 answer 106 views
106 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 454 views
454 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, 2020 jwilliam 3.9k points
0 votes
1 answer 6 views
6 views
I received an error message when converting data type varchar to numeric I imported data into VARCHAR column to check correct character types before moving into the destination table. I ran across some decimal values they could not CAST or CONVERT even though they ... values. I received the message "Error converting data type varchar to numeric.” How can I load these problems values?
asked Nov 24, 2020 miki 1.9k points
1 vote
1 answer 129 views
129 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, 2020 Martin K 6.6k points
1 vote
1 answer 20 views
20 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, 2020 morrisBson 3.2k points
0 votes
1 answer 17 views
0 votes
1 answer 197 views
197 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
0 votes
2 answers 516 views
516 views
Problem : I want to import the flat file into my oledb target sql server database. But I am getting below error message : [Source - 18942979103_txt [424]] Error: Data conversion failed. The data conversion for column "recipient-name" returned status value 4 and status text ... more characters had no match in the target code page.". Why am I getting this error message? What am I doing wrong here?
asked Dec 23, 2019 alecxe 7.5k points