Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 DATEDIFF for Milliseconds!?

Author  Topic 

edwardkoo
Starting Member

1 Post

Posted - 2009-03-19 : 03:09:31
Hi,

I need to find out the milliseconds difference between two date.
I tried the following,

1) SELECT DATEDIFF(ms, '2009-03-18 18:00:49.300' ,'2009-03-18 18:00:49.301') as msec

Return 0, it should be 1!?

2) SELECT DATEDIFF(ms, '2009-03-18 18:00:49.300' ,'2009-03-18 18:00:49.302') as msec

Return 3, it should be 2!?

Anyone know what's the logic behind the above results and is there a way to get accurate result?

Thanks.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-03-19 : 03:55:45
For SQL Server 2000 and SQL Server 2005, the smallest time resulution available is 3.33333 ms.
If you want your own subtraction, write your own function and parse the datetime as string.


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-19 : 12:44:59
quote:
Originally posted by edwardkoo

Hi,

I need to find out the milliseconds difference between two date.
I tried the following,

1) SELECT DATEDIFF(ms, '2009-03-18 18:00:49.300' ,'2009-03-18 18:00:49.301') as msec

Return 0, it should be 1!?

2) SELECT DATEDIFF(ms, '2009-03-18 18:00:49.300' ,'2009-03-18 18:00:49.302') as msec

Return 3, it should be 2!?

Anyone know what's the logic behind the above results and is there a way to get accurate result?

Thanks.


whats the version of sql server you're using?
Go to Top of Page
   

- Advertisement -