select * from rls  where datepart(hh,begintime)=19

解决方案 »

  1.   

    select * from rls  where datepart(hh,begintime  ) = 19
      

  2.   

    如果附加日期条件,则:
    select * from rls  where datepart(hh,begintime)=19 and begintime between '开始日期' and '结束日期'
      

  3.   

    你的begintime是字符串型的数据?select * from rls  where substirng(begintime , 11,2) = '19'
      

  4.   

    substirng(begintime , 11,2)中的11,2是怎么来的?
      

  5.   

    declare @t table(begintime varchar(20),bss int, bts int )
    insert @t select '2009-03-25 17:00',          0    ,                1 
    insert @t select '2009-03-25 18:00',          0    ,                2 
    insert @t select '2009-03-25 19:00',          0    ,                3 
    insert @t select '2009-03-25 17:00',          0    ,                1 
    insert @t select '2009-03-25 18:00',          0    ,                2 
    insert @t select '2009-03-25 19:00',          0    ,                3
    select * from @t  where datepart(hh,begintime)=19 begintime            bss         bts
    -------------------- ----------- -----------
    2009-03-25 19:00     0           3
    2009-03-25 19:00     0           3(2 行受影响)测了一下,如果是字符串,也会转换过来,可不用加引号。