2011-01-29 10:00:00数据表中有如下格式的字符串,能否在查询语句中,将时间这一列与系统当前时间比较,只返回时间大于当前系统时间的数据。

解决方案 »

  1.   


    select *
    from tb
    where data > getdate()
      

  2.   


    declare @table table (dtime datetime)
    insert into @table
    select '2011-01-29 10:00:00' union all
    select '2011-01-30 10:00:00' union all
    select '2011-01-31 10:00:00' union all
    select '2011-02-01 10:00:00' union all
    select '2010-08-09 10:00:00' union all
    select '2011-09-09 10:00:00'select * from @table where dtime>getdate()
    /*
    dtime
    -----------------------
    2011-01-31 10:00:00.000
    2011-02-01 10:00:00.000
    2011-09-09 10:00:00.000
    */
      

  3.   

    select * from tb where datediff(ss,date1,getdate())>0