这是我的基本“测试”
select DATEADD(ms,-2,DATEADD(dd,DATEDIFF(dd,getdate()),0)),0),case when DATEADD(ms,0)) != DATEADD(dd,0) then 'No Match' else 'Match' end union all select DATEADD(ms,-1,0) then 'No Match' else 'Match' end
我试图理解为什么MS -2,减去3和MS -1减去没有.
解决方法
MSsql的日期时间数据类型的最细粒度为.00333333(重复),或大约3毫秒.小于此值的变化将导致无变化或舍入为3.
从https://msdn.microsoft.com/en-us/library/cc280460.aspx起
datetime2(3) has a precision of one millisecond,and datetime has a precision of 1/300 of a second.