select * from [Table] where lasttime(day,5,Datecol)>getdate()  

解决方案 »

  1.   

    select   *   from   yourtable   where   datediff(yy,日期字段,getdate())>=0   and   datediff(yy,日期字段,getdate())   <   =5 
      

  2.   

    select * from tableName where datediff(day,lasttime,getdate())<=5
      

  3.   

    select * from tableName where datediff(day,lasttime,getdate())>=0 and datediff(day,lasttime,getdate())<=5
      

  4.   

    显示:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'getdate())<=5' at line 1 
      

  5.   

    上面的都出错啊,我用的是MYSQL
      

  6.   

    汗!你把内置函数换换还不行?
    不中数据库中有不同的内置函数.这样死般.
    肯定不行啦!
    你刚又没说你的是mysql啊.
    查查mysql的内置函数..
      

  7.   

    呵呵,发现在php版问的sql语句80%是mysql的
    mysql手册查date_sub函数
      

  8.   

    补充一下foolbirdflyfirst的回答SELECT DATE_SUB(current_date,INTERVAL 1 DAY); SELECT DATE_SUB(curdate(), INTERVAL 1 DAY); 
    mysql> select date_sub(curdate(),interval 1 day); 
    +------------------------------------+ 
    | date_sub(curdate(),interval 1 day) | 
    +------------------------------------+ 
    | 2006-06-19 | 
    +------------------------------------+ 
    1 row in set (0.09 sec) mysql> select date_sub('2006-06-04',interval 1 day); 
    +---------------------------------------+ 
    | date_sub('2006-06-04',interval 1 day) | 
    +---------------------------------------+ 
    | 2006-06-03 | 
    +---------------------------------------+ 
    1 row in set (0.00 sec)
      

  9.   


    select * from Table where datediff(d,lasttime,getdate())<=5 and datediff(d,lasttime,getdate()) >0