Msg 296, Level 16, State 3, Line 1
The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value.
This error message appears, when SQL Server cannot convert a character string into a valid SMALLDATETIME value.
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. When converting into a SMALLDATETIME data type, the value must be within the valid range for this type.
All versions of SQL Server.
SELECT CAST(‘18991231’ AS SMALLDATETIME)
In the above example the string ‘18991231’ is beyond the valid range of values for the SMALLDATETIMEdata type. As soon as the value is within the valid range, SQL Server automatically takes care of the conversion. To avoid any suprises, one needs to be aware of the rounding habits for the SMALLDATETIME data type. Because this type has only a precision of 1 minute, SQL Server rounds seconds (incl. Milliseconds) > 30.001 up to the nearest higher full minute. Values < 29.997 are rounded down to the nearest lower full minute.