How can I add exactly 1 millisecond?

不羁岁月 提交于 2020-01-30 05:05:16

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!