DAY() in MySQL — How It Works
What the MySQL DAY() function does, with an example.
Published October 20, 2026
DAY(date) returns the day of the month (1–31); DAYOFMONTH is a synonym. DAYOFWEEK and DAYOFYEAR return other day numbers.
How it works
Use it to extract or group by day.
Try it in MySQL
SELECT DAY('2026-11-12')
12
SELECT DAYOFWEEK('2026-11-12')
5
SELECT DAYOFYEAR('2026-11-12')
316
Practical examples
Example 1
SELECT DAY('2026-11-12');
-- 12Example 2
SELECT DAYOFWEEK('2026-11-12');
-- 5Example 3
SELECT DAYOFYEAR('2026-11-12');
-- 316Use it in a real query
SELECT id, DAY('2026-11-12') AS result
FROM your_table
LIMIT 10;Common mistakes
- Confusing DAY with DAYOFWEEK.
- DAYOFWEEK starting on Sunday = 1.
- Using in WHERE on indexed columns.
Key takeaways
- DAY() in one line: DAY(date) returns the day of the month (1–31); DAYOFMONTH is a synonym.
- Try queries in a test database first.
- Check NULL handling and data types.
FAQ
First day of month?
DATE_FORMAT(d, '%Y-%m-01').
Does DAY() work in other databases?
Most have an equivalent, but names and syntax vary between MySQL, PostgreSQL, SQL Server and SQLite.