This article provides a solution to a problem you may occasionally encounter while using the DATEDIFF()
function in SQL Server.
If you encounter the following error:
The datediff function resulted in an overflow. The number of dateparts separating two date/time instances is too large. Try to use datediff with a less precise datepart.
It’s because the return value is too large. The DATEDIFF()
function returns its result as an int data type. The reason you got this message is that the return value is too big for the int data type. Fortunately there’s an easy way to fix this.