select * from teachermsg where in_time>DATEADD(s,-5,getDAte())

解决方案 »

  1.   

    select * from teachermsg where in_time>=DATEADD(s,-5,getDAte())
    select * from teachermsg where DATEDIFF(s,in_time,getDate())<=5--原理:
    SELECT getdate(),DATEADD(s,-5,getDAte()),DATEDIFF(s,'2003-02-28 20:58:23',getDate())
      

  2.   

    select * 
    from teachermsg 
    where DATEDIFF(s,in_time,getDate())<=5
      

  3.   

    我的天啊
    这么多星星阿
    我只有一个星星(还不是这个板块)
    吓死我了我的数据库是mysql
    好像不可以吧!
    各位有什么注意吗?
      

  4.   

    sql的我都写出来了!另还有N个方法!但较常用的就是它们了!
    mysql你要去看看有什么支持的函数!用函数去做,会方便一点!你可以把这贴转到mysql版去问问!页面上按管理!
      

  5.   

    dateadd(ss,5,in_time)>getdate()
      

  6.   

    where in_time>dateadd(ss,-5,getdate())
      

  7.   

    非常感谢
    这个板块的哥们真热心
    非常非常感动ing.......................
      

  8.   

    用datediff(s,in_time,getdate())<5做条件。
      

  9.   

    select ????????????? where in_time >= NOW()-5;
      

  10.   

    swotcoder(苦 丁)老兄的最好啦, mysql> SELECT NOW()-0,NOW()-5;
    +----------------+----------------+
    | NOW()-0        | NOW()-5        |
    +----------------+----------------+
    | 20030313230317 | 20030313230312 |
    +----------------+----------------+
    1 row in set (0.00 sec)#两日期/时间之间相差的天数:  
    To_Days(end_time)-To_Days(start_time)  
     
    #两日期/时间之间相差的秒数:  
    SELECT  UNIX_TIMESTAMP(end_time)-  UNIX_TIMESTAMP(start_time);  
     
    #两日期/时间之间相差的时分数:  
     
    SELECT  SEC_TO_TIME(UNIX_TIMESTAMP(end_time)-  UNIX_TIMESTAMP(start_time));