Arithmetic overflow error converting expression to data type datetime

Found the problem to be when a date was set to 9999-12-31, probably to big for the decimal to handle. Changed from decimal to float, and every thing is working like a charm.


In general, converting a date to a numeric or string, to perform date operations on it, is highly inefficient. (The conversions are relatively intensive, as are string manipulations.) It is much better to stick to just date functions.

The example you give is (I believe) to strip away the time part of the DateTime, the following does that without the overhead of conversions...

DATEADD(DAY, DATEDIFF(DAY, 0, <mydate>), 0)

This should also avoid arithmentic overflows...