I want to convert datetime sql server to milliseconds. I tried converting it with a dated function, as shown below:
select cast(Datediff(ms, '1970-01-01',GETUTCDATE()) AS bigint)
But this gives me this error:
Msg 535, Level 16, State 0, Line 2 A dated function led to overflow. The number of dates separating two instances of date / time is too large. Try using a less accurate date datiff.
I do not want to do it like this:
select cast(Datediff(minute, '1970-01-01',GETUTCDATE()) AS bigint)*60*1000
Because it will not give me exact results. Can someone please help me with this?
source
share