Monday, March 19, 2012

[SQL2000] dateadd (millisecond) problem

select dateadd(millisecond,-1,convert(datetime,'20080101 0: 0: 0',112))
why isn't it 20061231 23:59:59.999 ?
--
SoftMedia Technology Co., Ltd.
Website: http://www.softmedia.hk Tel: (852)2743 4228
* TryEasy Accounting/POS/Trading/ERP solutionsThere is a rounding issue associated with millisecond values. Please take a
look at this link for more details:
http://www.sql-server-performance.com/forum/topic.asp?ARCHIVE=true&TOPIC_ID=908
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com|||"Man-wai Chang" <info@.softmedia.hk> wrote in message
news:uvGIDscxGHA.4444@.TK2MSFTNGP02.phx.gbl...
> select dateadd(millisecond,-1,convert(datetime,'20080101 0: 0: 0',112))
> why isn't it 20061231 23:59:59.999 ?
Please have a look in BOL at the information about the datetime datatype.
You are assuming that the datatype is accurate to 1 ms - this is not a valid
assumption. You should also review the information in the following link
http://www.karaszi.com/sqlserver/info_datetime.asp

No comments:

Post a Comment