当前位置: 代码迷 >> Sql Server >> 以Datetime类型为条件的查询怎么写
  详细解决方案

以Datetime类型为条件的查询怎么写

热度:44   发布时间:2016-04-27 12:23:43.0
以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'
  相关解决方案