Russell Horn wrote:
I have a table containing a timestamp field, `insert_time`

The manual is clear when it comes to selecting records from the past
week or month, I can use:

SELECT COUNT(*) FROM statistics WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= `insert_time`;

What I am less sure about is how I would select records that had been
inserted to thee table in the previous hour.

I understand the date functions will ignore the hh:mm:ss - will the time
functions ignore the date? Can anyone suggest what function I need for
this select?

Thanks,

Russell.




Rather than the CURDATE() function, just use NOW().

Ex.:

mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2006-01-19 14:47:50 |
+---------------------+
1 row in set (0.00 sec)

mysql> select date_sub(now(), interval 1 hour);
+----------------------------------+
| date_sub(now(), interval 1 hour) |
+----------------------------------+
| 2006-01-19 13:47:53              |
+----------------------------------+
1 row in set (0.00 sec)


Cheers :)


--
Devananda vdv


http://devananda-vdv.blogspot.com/
http://mycat.sourceforge.net/

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to