In SQL Server, you can use the DATEDIFF_BIG()
function instead of the DATEDIFF()
function if you expect the returned value to be really big. For example, if you’re trying to find out how many milliseconds are in a 1000 years, you’ll get an error.
That’s because DATEDIFF()
returns an int data type, and the result is too big for that data type to handle. On the other hand, the DATEDIFF_BIG()
function returns a signed bigint data type, which means you can use it to return much larger values. In other words, you can use with a much larger range of dates.
Other than that, there’s not really any difference between the two functions.
The article provides examples of using the DATEDIFF_BIG()
function in SQL Server.
Continue reading →