ID                     date
F44FC345B10F050 2006/01/03 21:29:24
F44FC38A910F050 2006/01/07 01:25:38
F44FC3EE510F050 2006/01/03 23:32:22
F488035EB10F050 2006/01/05 08:38:50
F50B42AFC10F050 2006/01/03 13:35:32
F50B42AFC10F050 2006/01/08 23:55:12比如
以上数据,想查询12:00~20:00的ID(不管日期,只看具体时间)
谢谢啦!

解决方案 »

  1.   

    select *
    from table 
    where datepart(date,hh) >=12 and datepart(date,hh) <= 20
      

  2.   

    select *
    from table 
    where datepart(date,hh) BETWEEN 12 and 20
      

  3.   

    select * from table
    where substrint(convert(varchar,[date],120),12,16) between '12:05' and '20:15'
      

  4.   

    select * from table
    where substring(convert(varchar,[date],120),12,16) between '12:05' and '20:15'
      

  5.   

    select *
    from table 
    where datepart(date,hh) >=12 and datepart(date,hh) < 21
      

  6.   

    --或者
    select * from table
    where substrint(convert(varchar,[date],108),1,5) between '12:05' and '20:15'
      

  7.   

    select *
    from table 
    where  DATEPART(hour, [date]) between 12 and 20
      

  8.   

    谢谢大家!
    最终采用(施主,给个妞泡好么)的方案select * from table
    where substrint(convert(varchar,[date],108),1,5) between '12:05' and '20:15'