mysql last month code example
Example 1: mysql get last day of month
SELECT LAST_DAY(CURDATE()); -- Current month
SELECT LAST_DAY(CURDATE() - INTERVAL 1 MONTH); -- Previous month
SELECT LAST_DAY(CURDATE() + INTERVAL 1 MONTH); -- Next month
Example 2: mysql last friday of current month
SELECT LAST_DAY(NOW()) - ((7 + WEEKDAY(LAST_DAY(NOW())) - 4) % 7);
Example 3: mysql last 6 months
.... where yourdate_column > DATE_SUB(now(), INTERVAL 6 MONTH)