Difference of two datetime columns caused overflow at runtime.

Error Message:
Msg 535, Level 16, State 0, Line 1
Difference of two datetime columns caused overflow at runtime.

Severity level:

This error message appears when you try to “subtract” two values of the type (SMALL)DATETIME and the resulting value causes an overflow

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. The statement cannot be executed this way. You cannot subtract these two values using your specified interval in one go. You might need to perform an intermediate step to get to the desired result.

All versions of SQL Server.

SELECT DATEDIFF(MILLISECOND, ’19000101′, ’99991231′)

In the above example the result in milliseconds between the two shown values causes the overflow an raises the error.


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 |