查询当天
.....
select * from table where date(regdate)=curdate();
date()函数获取日期部分,扔掉时间部分,然后与当前日期比较即可
mysql> select curdate();
+------------+
| curdate() |
+------------+
| 2015-01-05 |
+------------+
一周
select * from phome_ecms_news where newstime > UNIX_TIMESTAMP()-86400*30 order by onclick desc limit 100
mysql> select unix_timestamp(now()),unix_timestamp();
+-----------------------+------------------+
| unix_timestamp(now()) | unix_timestamp() |
+-----------------------+------------------+
| 1420442559 | 1420442559 |
+-----------------------+------------------+
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2015-01-05 15:23:07 |
+---------------------+
转载请注明:谷谷点程序 » Mysql 查询当天 一周 数据方法