Conversion failed when converting datetime from character string.

Error Message:
Msg 241, Level 16, State 1, Line 3
Conversion failed when converting datetime from character string.

Severity level:
16.

Description:
This error message appears, when SQL Server cannot convert a string to a valid DATETIME value.

Consequences:
The T-SQL statement can be parsed, but causes the error at runtime.

Resolution:
Error of the Severity level 16 are generated by the user and can be fixed by the SQL Server user.

Versions:
All versions of SQL Server.

Example(s):
DECLARE @dt VARCHAR(10)
SET @dt = ‘2007011’
SELECT CAST(@dt AS DATETIME)

Remarks:
Invalid string values that should be converted are a frequent source of errors. One way to check if a string can be converted into a valid DATETIME value, is the use of the ISDATE() funktion.




Array

No comments yet... Be the first to leave a reply!