sql="select * from youtable where datediff(d,[time],getdate())>7"sql="select * from youtable where datediff(d,[time],getdate())>14"sql="select * from youtable where datediff(d,[time],getdate())>30"

解决方案 »

  1.   

    datediff 这个是mysql函数吗,好像没有的?
      

  2.   

    $days=date("w")==0?7:date("w");///本周内,date("w")得到当天是星期几,星期天是0,其余为1-6
    $days=date("w")==0?14:date("w")+7;///两周内,这个不用说了
    $days=intval(date("d"));//本月内$sql="select * from table_name where to_days(now())-to_days(time)<$days";///重点是使用MYSQL的to_days来做日期差剩下的就简单了。