Msg 535, Level 16, State 0, Line 1
Difference of two datetime columns caused overflow at runtime.
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.