日期:2014-05-19  浏览次数:20788 次

求一段SQL来确定当天的时间范围
比如:

2007-04-23   19:04:51.000

我就需要

2007-04-23   0:00:00.000
2007-04-23   23:59:59.000

来确定是当天的数据,知道的回我一下,谢谢~

------解决方案--------------------
Returns the number of date and time boundaries crossed between two specified dates.
DATEDIFF ( datepart , startdate , enddate )

你使用 DATEDIFF(day, '2007-04-23 19:04:51.000 ', datetimefield) = 0 就可以了

------解决方案--------------------
麻烦
直接看看等不等于convert(varchar(10),getdate(),111)
就行了
------解决方案--------------------
确定是否是当天
convert(varchar,convert(datetime, '2007-04-23 19:04:51.000 '),112) = convert(varchar,getdate(),112)
------解决方案--------------------
DATEDIFF(day, '这里是最后一个时间。。。 ', datetimefield) = 0
或者
DATEDIFF(day, datetimefield, '这里是最后一个时间。。。 ') = 0