日期:2014-05-17 浏览次数:20469 次
declare @T table([开始时间] datetime,[结束时间] datetime) insert @T select '2012-08-15 09:00:00','2012-08-15 10:00:00' union all select '2012-08-16 09:00:00','2012-08-16 10:00:00' union all select '2012-08-15 10:00:00','2012-08-15 11:00:00' union all select '2012-08-15 11:00:00','2012-08-15 12:00:00' select * from @T where datepart(hh,开始时间)=9 and (datepart(hh,结束时间) in (9,10)) /* 开始时间 结束时间 ----------------------- ----------------------- 2012-08-15 09:00:00.000 2012-08-15 10:00:00.000 2012-08-16 09:00:00.000 2012-08-16 10:00:00.000 */