mysql query get date of 1 month interval

Very often we need to extract last 1 month, 2 months data from mysql DB. Here we will show easy way to get the data of given interval.

SELECT * from testtable
WHERE startdate BETWEEN DATE_SUB(NOW(), INTERVAL 1 MONTH) AND
                        DATE_SUB(NOW(), INTERVAL 2 MONTH)


The above query will return records whose order date is between one and two months.

Leave a Reply