Get First day of last month and last day of last month

SET @YEAR = DATE_FORMAT(NOW(), '%Y');

SET @MONTH = DATE_FORMAT(NOW(), '%m');

SET @DAY = '01';

SET @DATE_LAST_MONTH = DATE_FORMAT(DATE_SUB(LAST_DAY(NOW() - INTERVAL 1 MONTH) + INTERVAL 1 DAY, INTERVAL 1 MONTH), '%Y/%m/%d');

SET @LAST_DAY_OF_LAST_MONTH = DATE_FORMAT(LAST_DAY(@DATE_LAST_MONTH), '%Y/%m/%d');

SELECT @DATE_LAST_MONTH, @LAST_DAY_OF_LAST_MONTH

Comments

Popular Posts