I advised a developer to compare dates with milliseconds, but it ended up blowing up with overflow. If you compare the milliseconds for dates that are months apart, it is a very large number!
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.
A way around this is to compare the dates by minutes first, and then apply the milliseconds comparision. This will prevent the comparison of dates that are too wide apart.
WHERE DATEDIFF( m, Date1, Date2 ) < 1
AND DATEDIFF( ms, Date1, Date2 ) < 500