Find the date a week ago : DATE_SUB « Date Time « SQL / MySQL






Find the date a week ago

     
mysql>
mysql> SELECT CURDATE( ), DATE_SUB(CURDATE( ),INTERVAL 7 DAY);
+------------+-------------------------------------+
| CURDATE( ) | DATE_SUB(CURDATE( ),INTERVAL 7 DAY) |
+------------+-------------------------------------+
| 2011-10-03 | 2011-09-26                          |
+------------+-------------------------------------+
1 row in set (0.00 sec)

mysql>

   
    
    
    
    
  








Related examples in the same category

1.Calculated dates are useful for range testing
2.Calculate the last day of the month for the previous, current, and following months relative to a given date,
3.Finding First and Last Days of Months
4.Finding the Length of a Month
5.The last day of the previous month is a special case for which the general expression can be simplified quite