The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

Error Message:
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.

Severity level:
16.

Description:
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.

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 = ’17520101′
SELECT CAST(@dt AS DATETIME)

Remarks:
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.




Related Articles :

  • No Related Articles Found

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

Software Reviews | Book Reviews | FAQs | Tips | Articles | Performance Tuning | Audit | BI | Clustering | Developer | Reporting | DBA | ASP.NET Ado | Views tips | | Developer FAQs | Replication Tips | OS Tips | Misc Tips | Index Tuning Tips | Hints Tips | High Availability Tips | Hardware Tips | ETL Tips | Components Tips | Configuration Tips | App Dev Tips | OLAP Tips | Admin Tips | Software Reviews | Error | Clustering FAQs | Performance Tuning FAQs | DBA FAQs |