Msg 242, Level 16, State 3, Line 3
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
This error message appears, when SQL Server tries to convert a string to a DATETIME value and encounters that the resulting value is outside the valid range for DATETIME values.
The T-SQL statement can be parsed, but causes the error at runtime.
Error of the Severity level 16 are generated by the user and can be fixed by the SQL Server user.
All versions of SQL Server.
DECLARE @dt VARCHAR(10)
SET @dt = ‘17520101’
SELECT CAST(@dt AS DATETIME)
SQL Server offers a range of DATETIME values between 01/01/1753 and 12/31/9999. Values that are beyond this range cannot be stored in a column of the DATETIME type and any attempt raises this error.