MSSQL DATEDIFF accuracy
Posted
by jomi
on Stack Overflow
See other posts from Stack Overflow
or by jomi
Published on 2010-04-27T08:13:18Z
Indexed on
2010/04/27
8:23 UTC
Read the original article
Hit count: 461
Hello,
I have to store some intervals in mssql db. I'm aware that the datetime's accuracy is approx. 3.3ms (can only end 0, 3 and 7). But when I calculate intervals between datetimes I see that the result can only end with 0, 3 and 6. So the more intervals I sum up the more precision I loose. Is it possible to get an accurate DATEDIFF in milliseconds ?
declare @StartDate datetime
declare @EndDate datetime
set @StartDate='2010-04-01 12:00:00.000'
set @EndDate='2010-04-01 12:00:00.007'
SELECT DATEDIFF(millisecond, @StartDate, @EndDate),@EndDate-@StartDate, @StartDate, @EndDate
I would like to see 7 ad not 6. (And it should be as fast as possible)
Thanks,
© Stack Overflow or respective owner