Yes, SQL Server rounds the time to 3.(3) milliseconds:
SELECT CAST(CAST('2009-01-01 00:00:00.000' AS DATETIME) AS BINARY(8)) SELECT CAST(CAST('2009-01-01 00:00:01.000' AS DATETIME) AS BINARY(8)) 0x00009B8400000000 0x00009B840000012C
As you can see, these DATETIME differ by 1 second, and their binary representations differ by 0x12C , i.e. 300 in decimal.
This is because SQL Server stores the time part of the DATETIME as the number of 1/300 second ticks from midnight.
If you need higher precision, you need to keep the time part as a separate value. For example, the storage time is rounded to the second, like DATETIME , and milliseconds, or any other precision that you need as INTEGER in other columns.
This will allow you to use complex DATETIME arithmetic, for example, add months or find the days of the week on DATETIME , and you can simply add or subtract milliseconds and combine the result as .XXXXXX+HH:MM to get the validity of the XML representation.
Quassnoi Mar 11 '09 at 11:21 2009-03-11 11:21
source share