日期:2014-05-18  浏览次数:20565 次

以Datetime类型为条件的查询如何写?
我有一组数据,
A, 2012-06-01 07:01:00.000
B, 2012-06-01 17:01:00.000
C, 2012-06-02 07:02:00.000
D, 2012-06-02 17:02:00.000
E, 2012-06-03 07:03:00.000
F, 2012-06-03 17:03:00.000

我只需要每天17点的多的那笔数据,查询语句该如何写?


------解决方案--------------------
select * from tbl where hour(date)=17
------解决方案--------------------
SQL code
select * from tb where datepart(hh,时间)=17

------解决方案--------------------
SQL code
select * from tb where right(CONVERT(varchar(30),col,120),12)>='17:00:00.000' and right(CONVERT(varchar(30),col,120),12)<'18:00:00.000'