conversion of a varchar data type to a datetime data type resulted in an out-of-range value

后端 未结 7 2407
梦毁少年i
梦毁少年i 2020-11-27 06:33

I have the following piece of inline SQL that I run from a C# windows service:

UPDATE table_name SET 
    status_cd = \'2\', 
    sdate = CAST(\'03/28/2011 1         


        
7条回答
  •  無奈伤痛
    2020-11-27 07:23

    I know that this solution is a little different from the OP's case, but as you may have been redirected here from searching on google the title of this question, as I did, maybe you're facing the same problem I had.
    Sometimes you get this error because your date time is not valid, i.e. your date (in string format) points to a day which exceeds the number of days of that month! e.g.: CONVERT(Datetime, '2015-06-31') caused me this error, while I was converting a statement from MySql (which didn't argue! and makes the error really harder to catch) to SQL Server.

提交回复
热议问题