klenwell information services : MysqlInterval

Revision [1463]

This is an old revision of MysqlInterval made by KlenwellAdmin on 2010-07-07 09:04:33.
 

Mysql Interval

return to DevMysql

Examples

mysql> SELECT DATE(NOW()) - INTERVAL 1 DAY;
+------------------------------+
| DATE(NOW()) - INTERVAL 1 DAY |
+------------------------------+
| 2010-07-06                   |
+------------------------------+
1 row in set (0.00 sec)

mysql> SELECT DATE(NOW()) - INTERVAL 1 DAY;
+------------------------------+
| DATE(NOW()) - INTERVAL 1 DAY |
+------------------------------+
| 2010-07-06                   |
+------------------------------+
1 row in set (0.00 sec)

SET @d='2010-06-01'
SELECT COUNT(*) AS transaction_count FROM transactions WHERE lastupdate >= @d - INTERVAL 1 DAY and lastupdate < @d;


References

http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-add