问题描述
亲爱的,
如果您签入sql请尝试以下查询
选择DATEDIFF(月, '10 / 21/2012','6/1/2013')
它给你8个月,但如果手动计算,天数是223和223/30给出你有7.43
有什么理由吗?
谢谢
巴斯特。
Dear,
If you check in sql try below query
select DATEDIFF(MONTH,'10/21/2012','6/1/2013')
it gives you 8 month but if calculate manually the days is 223 and 223/30 gives you 7.43
Is there any reason?
Thanks
Basit.
推荐答案
选择DATEDIFF(月,'10 / 21/2012','6/1/2013')
它给你8个月,但如果手动计算天数是223和223/30给你7.43
select DATEDIFF(MONTH,'10/21/2012','6/1/2013')
it gives you 8 month but if calculate manually the days is 223 and 223/30 gives you 7.43
是的,它是.DateDiff函数你正在使用返回dif几个月,但不是天除以30.请注意,月份的月份不同。一旦它可能是28/29(二月),一次30/31。
Yes, it is. The DateDiff function you're using returns the difference in months, but not days divided by 30. Note that days in month differ between months. Once it could be 28/29 (February), once 30/31.
这篇关于SQL Datediff在两个日期和返回月份之间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!