MySQL Date Math

SELECT DATE_SUB(CURDATE(), INTERVAL 30 DAY);
SELECT DATE_SUB(CURDATE(), INTERVAL 1 MONTH)
SELECT DATE_SUB(CURDATE(), INTERVAL 3 MONTH)
SELECT DATE_SUB(CURDATE(), INTERVAL 6 MONTH)
SELECT DATE_SUB(CURDATE(), INTERVAL 12 MONTH)
SELECT DATE_SUB(CURDATE(), INTERVAL 18 MONTH)

SELECT DATE_SUB(CURDATE(), INTERVAL 24 MONTH)
SELECT DATE_SUB(CURDATE(), INTERVAL 10 YEAR)
SELECT DATE_SUB(CURDATE(), INTERVAL 100 YEAR)

1997-11-01

SELECT COUNT( `WB1` ) FROM `PB` WHERE `WB1` =  15 and `DDate` >= DATE_SUB(CURDATE(), INTERVAL 10 MONTH)



CURDATE()
  • Returns the current date as a value in 'YYYY-MM-DD' or YYYYMMDD format, depending on whether the function is used in a string or numeric context.
    mysql> SELECT CURDATE();
            -> '2008-06-13'
    mysql> SELECT CURDATE() + 0;
            -> 20080613