如何在sql server 2005中使用DATEDIFF [英] How To Use DATEDIFF in sql server 2005
本文介绍了如何在sql server 2005中使用DATEDIFF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
当我尝试在sql server 2005中的分钟之间进行差异时,我试试这段代码工作正常
Hi All,
when i try to diff between minute in sql server 2005, it i try this code working fine
select datediff(minute, '2011-01-02 12:00:00', '2011-01-02 12:30:00') as minutes
但这段代码显示错误,你能帮我解决这个问题吗?
But This code showing Error, can you help me how to slove this one
SELECT DATEDIFF(minute, '2005-12-31 23:59:59.9999999', '2006-01-01 00:00:00.0000000');
谢谢!
Thanks!
推荐答案
试试这个:
Try this:
SELECT DATEDIFF(minute, '2005-12-31T23:59:59.999', '2006-01-01T00:00:00.999');
在日期和时间之间加一个'T',只用3位数毫秒
Put a 'T' between date and time,and use just 3 digits for milliseconds
试试这个...
Hi,
Try this...
SELECT DATEDIFF(minute, '2005-12-31 23:59:59.999', '2006-01-01 00:00:00.000');
希望这会对你有所帮助。
干杯。
Hope this will help you.
Cheers.
这篇关于如何在sql server 2005中使用DATEDIFF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文