一、
select * from SearchDetails where SearchDateTime between '2014-10-06 01:40:50.123' and '2014-12-07 23:12'
and datepart(hour, SearchDateTime) between 1 and 12 --这里是字符串隐式转换为Datetime(尽量不要精确到毫秒,会有误差)
二、
select * from 表 where 日期字段>='开始日期' and 日期字段<='截止日期'
and convert(char(8),日期字段,108)>='开始时间' and convert(char(8),日期字段,108)<='截止时间'例如:select * from tb1 where dDate>='2010-11-05' and dDate<='2010-11-15'and convert(char(8),dDate,108)>='22:30:00' and convert(char(8),dDate,108)<='23:00:00'
三、
表table1,字段d,如下
select * from table1where year(d)=2010 and month(d)=7 and day(d) between 1 and 31and (Datepart(hour,d)>=22 or Datepart(hour,d)<6)