MySQL + SQL · Lesson 1
First Last Day Month
Month Boundaries
MySQL can find the first and last day of the current (or any) month using built-in date functions.
The Queries
-- first day of current month
SELECT DATE_FORMAT(CURDATE(), '%Y-%m-01') AS first_day;
-- last day of current month
SELECT LAST_DAY(CURDATE()) AS last_day;first_day: 2026-06-01
last_day: 2026-06-30
Summary
- First day:
DATE_FORMAT(CURDATE(), '%Y-%m-01'). - Last day:
LAST_DAY(CURDATE()).
💻 Live Code Editor
This page's programs are ready here — run them, edit them, and learn. No installation needed.
Powered by OneCompiler. The code loads into the editor automatically — press Run to see the output. If the editor does not open, open it in a new tab.