这样应该行的
where time between '2001-11-1 1:00:00' and '2001-11-29 23:00:00'

解决方案 »

  1.   

    where datepart(yy,time)=2001 
        and datepart(mm,time)=11这样也行的
      

  2.   

    这样的问题是很麻烦,通常可以通过临时表来实现:
    1.建立临时表数据
    insert into #tmp(day,hour,...)
    select datepart(dd,time),datepart(hh,time),...
    from table
    where datepart(yy,time)=2001 and datepart(mm,time)=11
    2。查询某天或某时数据
    select * 
    from #tmp
    where day in (1,2,3,4,5,...29)
    and hour in (1,2,3,...23)