表1
   F_code      F_name      F_time
   002         aaa         2006-10-21 14:42:21
   003         bbb         2006-10-21 14:43:31 把和当前时间比较,超过30秒的记录查询出来

解决方案 »

  1.   

    select * from [表1] where datediff(second,[F_time],getdate())>30
      

  2.   

    select * from [表1] where asb(datediff(second,[F_time],getdate()))>30吧
      

  3.   

    这样效率点好像select * from [表1] where [F_time]>dateadd(second,-30,getdate()) and [F_time]<dateadd(second,30,getdate())
      

  4.   

    declare @tab table(f_code char(6),F_name varchar(20),F_time datetime)
    insert @tab values('002','aaa','2006-10-21 14:42:21')
    insert @tab values('003','bbb','2006-10-21 14:43:31')select * from @tab where datediff(second,f_time,getdate())>30