Work needs to query this month, the data this month to ranking, a closer look at the database tutorial in the database stored in the date format is 2010-02-23 14:2:3 This type, so I think the database by the second query method is not, find a date added to reduce SQL function online DateDiff (Now,oldtime). The test can be done with the following I take my operating process out. [
SELECT * FROM t where DateDiff (now (), senddate) <31 order by click DESC LIMIT 0,10//Query one-month click Data Ranking
SELECT * FROM t where DateDiff (now (), senddate) <7 The order by click DESC LIMIT 0,10//query for one week of data
SELECT * FROM t where DateDiff (now (), senddate) <=1 The order by click DESC LIMIT 0,10//Identify the data for the day
This is more convenient to operate, about the now function, in the MySQL tutorial is recognizable, look at the example below.
Mysql> Select Now ();
+---------------------+
| Now () |
+---------------------+
| 2008-08-08 22:20:46 |
+---------------------+
OK, now is it convenient to add and subtract the date?