本帖最后由 qq35610 于 2012-07-24 11:17:38 编辑

解决方案 »

  1.   

    1,查询starttime大于当前服务器时间,并且在 三天内的结果
    select * from actives where starttime between UNIX_TIMESTAMP() and  UNIX_TIMESTAMP() + 3*24*60*60;2,查询starttime大于当前服务器时间,并且在 一周内的结果
    select * from actives where starttime between UNIX_TIMESTAMP() and  UNIX_TIMESTAMP() + 7*24*60*60;
    2,查询starttime大于当前服务器时间,并且在 一月内的结果
    select * from actives where starttime between UNIX_TIMESTAMP() and  UNIX_TIMESTAMP() + 30*24*60*60;
      

  2.   

    按照2楼的逻辑,是否可以改成这样
    1,查询starttime大于当前服务器时间,并且在 三天内的结果
    select * from actives where starttime > UNIX_TIMESTAMP() + 3*24*60*60+1;
      

  3.   

    1,查询starttime大于当前服务器时间,并且在 三天内的结果无法理解你想表达的到底是什么。
     where starttime > UNIX_TIMESTAMP() + 3*24*60*60+1;
    这个和你的要求根本不是一会事儿。
      

  4.   


    mysql> select date_add(now(),interval -1 day); 
    +---------------------------------+
    | date_add(now(),interval -1 day) |
    +---------------------------------+
    | 2012-07-23 13:20:24             |
    +---------------------------------+
    1 row in set (0.00 sec)mysql> select date_add(now(),interval -1 week);
    +----------------------------------+
    | date_add(now(),interval -1 week) |
    +----------------------------------+
    | 2012-07-17 13:20:29              |
    +----------------------------------+
    1 row in set (0.00 sec)mysql> select date_add(now(),interval -1 month);
    +-----------------------------------+
    | date_add(now(),interval -1 month) |
    +-----------------------------------+
    | 2012-06-24 13:20:32               |
    +-----------------------------------+
    1 row in set (0.00 sec)