问题
select getdate(),DATEADD(millisecond,1,getdate())
yields me same answer....How to add exactly 1 millisecond?
I cannot use a datetime2 field.
回答1:
You'll need to store milliseconds separately if you need that much accuracy. In SQL Server 2005 there is no native date/time type that will allow you to be more precise than ~3 ms. This is why, for example, the last time you can have in a day is 23:59:59.997, not .998 or .999.
回答2:
You can't. The accuracy of datetime is 3.33 milliseconds.
Date and Time
回答3:
The resolution of the DATETIME type is insufficient for your needs; per the documentation, it is:
Rounded to increments of .000, .003, or .007 seconds
回答4:
I think you can't, because DateTimes are represented as floating point number internally and 1 millisecond can not be represented as a float.
Please refer to the answers to this question for details.
来源:https://stackoverflow.com/questions/9804877/how-can-i-add-exactly-1-millisecond