Collections:
DAYOFWEEK() - Day of Week (1=Sunday)
How to extract the day of week of a given date using the DAYOFWEEK() function?
✍: FYIcenter.com
DAYOFWEEK(date) is a MySQL built-in function that returns the day of week from a given date. For example:
SELECT DAYOFWEEK('2023-02-03'), DAYNAME('2023-02-03'); -- +-------------------------+-----------------------+ -- | DAYOFWEEK('2023-02-03') | DAYNAME('2023-02-03') | -- +-------------------------+-----------------------+ -- | 6 | Friday | -- +-------------------------+-----------------------+ SELECT DAYOFWEEK(NOW()), DAYNAME(NOW()); -- +------------------+----------------+ -- | DAYOFWEEK(NOW()) | DAYNAME(NOW()) | -- +------------------+----------------+ -- | 3 | Tuesday | -- +------------------+----------------+
Reference information of the DAYOFWEEK() function:
DAYOFWEEK(date): int Returns the weekday index for date (1 = Sunday, 2 = Monday, ..., 7 = Saturday). Arguments, return value and availability: date: Required. The date to extract the day of week from. int: Return value. The day of week. Available since MySQL 4.
Related MySQL functions:
2023-11-16, 268🔥, 0💬
Popular Posts:
Where to find SQL Server database server tutorials? Here is a collection of tutorials, tips and FAQs...
How To Query Tables and Loop through the Returning Rows in MySQL? The best way to query tables and l...
How To Get Year, Month and Day Out of DATETIME Values in SQL Server Transact-SQL? You can use DATEPA...
How to change the data type of an existing column with "ALTER TABLE" statements in SQL Server? Somet...
How To Convert Numeric Expression Data Types using the CAST() Function in SQL Server Transact-SQL? I...