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

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

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

Versions:
All versions of SQL Server.

Example(s):
SELECT DATEDIFF(MILLISECOND, ‘19000101’, ‘99991231’)

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

]]>

Leave a comment

Your email address will not be published.