# For current month
SELECT DATE_FORMAT(CURDATE(), '%Y-%m-01') AS `First Day Of Current Month`;
SELECT LAST_DAY(CURDATE()) AS `Last Day Of Current Month`;
# For previous month
SELECT DATE_FORMAT(CURDATE() - INTERVAL 1 MONTH, '%Y-%m-01') AS `First Day Of Previous Month`;
SELECT LAST_DAY(CURDATE() - INTERVAL 1 MONTH) AS `Last Day Of Previous Month`;
# For next month
SELECT DATE_FORMAT(CURDATE() + INTERVAL 1 MONTH, '%Y-%m-01') AS `First Day Of Next Month`;
SELECT LAST_DAY(CURDATE() + INTERVAL 1 MONTH) AS `Last Day Of Next Month`;
SELECT DATE_FORMAT(CURDATE(), '%Y-%m-01') AS `First Day Of Current Month`;
SELECT LAST_DAY(CURDATE()) AS `Last Day Of Current Month`;
# For previous month
SELECT DATE_FORMAT(CURDATE() - INTERVAL 1 MONTH, '%Y-%m-01') AS `First Day Of Previous Month`;
SELECT LAST_DAY(CURDATE() - INTERVAL 1 MONTH) AS `Last Day Of Previous Month`;
# For next month
SELECT DATE_FORMAT(CURDATE() + INTERVAL 1 MONTH, '%Y-%m-01') AS `First Day Of Next Month`;
SELECT LAST_DAY(CURDATE() + INTERVAL 1 MONTH) AS `Last Day Of Next Month`;
Comments
Post a Comment