日期时间转换似乎有问题。

huangapple go评论58阅读模式
英文:

date time conversion seems off

问题

在某些情况下,它没有给我精确的数字,而是四舍五入到其他值。这正常吗?

CONVERT(varchar(125), dateadd(millisecond,ms,datetime), 21) as ZDateTimeMs

英文:

I encounter situation like this where I try to add Millisecond into my DateTime.

日期时间转换似乎有问题。

In some cases, it didn't give me the exact number and it got rounded to something else.
Is it normal ?

          CONVERT(varchar(125), dateadd(millisecond,ms,datetime), 21) as ZDateTimeMs 

答案1

得分: 1

datetime

datetime 值会被舍入到 .000、.003 或 .007 秒的增量,如下表所示。

用户指定值 系统存储值
01/01/98 23:59:59.999 1998-01-02 00:00:00.000
01/01/98 23:59:59.995
01/01/98 23:59:59.996
01/01/98 23:59:59.997
01/01/98 23:59:59.998 1998-01-01 23:59:59.997
01/01/98 23:59:59.992
01/01/98 23:59:59.993
01/01/98 23:59:59.994 1998-01-01 23:59:59.993
01/01/98 23:59:59.990
01/01/98 23:59:59.991 1998-01-01 23:59:59.990

英文:

From datetime:

datetime values are rounded to increments of .000, .003, or .007 seconds, as shown in the following table.

User-specified value System stored value

01/01/98 23:59:59.999 	1998-01-02 00:00:00.000
01/01/98 23:59:59.995

01/01/98 23:59:59.996

01/01/98 23:59:59.997

01/01/98 23:59:59.998 	1998-01-01 23:59:59.997
01/01/98 23:59:59.992

01/01/98 23:59:59.993

01/01/98 23:59:59.994 	1998-01-01 23:59:59.993
01/01/98 23:59:59.990

01/01/98 23:59:59.991 	1998-01-01 23:59:59.990

huangapple
  • 本文由 发表于 2023年2月8日 12:01:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/75381261.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定