having a current date as 2011/12/05
.. , how to get a date extract one month back ? 2011/11/05
? in MYsql?
You also can use
SELECT * FROM tableName WHERE createdDate >= (now() - INTERVAL 1 MONTH);
if you're looking for everything created in the last month.
mysql> SELECT DATE_SUB(20111205, INTERVAL 1 MONTH);
+--------------------------------------+
| DATE_SUB(20111205, INTERVAL 1 MONTH) |
+--------------------------------------+
| 2011-11-05 |
+--------------------------------------+
1 row in set (0.88 sec)
FOR MORE INFO: Date-Arithmetic-With-MySQL
select date_sub('2011-12-05',interval 1 month);
You can do this by adding condition to the WHERE:
created_at <= DATE_SUB(CURDATE(), INTERVAL 1 month)