Cast int to SmallDateTime

JoBaxter picture JoBaxter · Feb 15, 2013 · Viewed 7.2k times · Source

I am trying to compare L.LoanDueDate (which is a smalldatetime) to the return value of ufnARCUGetLatestProcessDate() (which is an int) to see how many days the loan due date is past the last process date.

I receive an

Arithmetic overflow error converting expression to data type smalldatetime

error and can't seem to figure it out. Any help would be useful. Thank you in advance.

CAST(L.LoanDueDate - CAST(CAST((SELECT ProcessDate FROM ufnARCUGetLatestProcessDate()) AS VARCHAR(10)) AS smalldatetime) AS INT)

Answer

DigCamara picture DigCamara · Feb 15, 2013

You can't compare an int to a smalldatetime. You need to compare two dates and for that you'd have to use datediff.