DATEDIFF interval=ms的用法

datediff(ms,@CurrDateTime,@Date)>0

上面的日期超过24天,用上面的sql会有问题

要修改成如下:

 (CONVERT(VARCHAR,@CurrDateTime,111)=CONVERT(VARCHAR,@Date,111) AND datediff(ms,@CurrDateTime,@Date)>0)

OR (CONVERT(VARCHAR,@CurrDateTime,111)<>CONVERT(VARCHAR,@Date,111) AND datediff(d,@CurrDateTime,@Date)>0))

 

For your references:

 

http://technet.microsoft.com/en-us/library/aa258269(v=sql.80).aspx

 

“DATEDIFF produces an error if the result is out of range for integer values. For milliseconds, the maximum number is 24 days, 20 hours, 31 minutes and 23.647 seconds. For seconds, the maximum number is 68 years.”

 

posted @ 2014-04-24 17:01  奋斗, 奋斗, 奋斗!  阅读(305)  评论(0编辑  收藏  举报