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, 1129🔥, 0💬
Popular Posts:
How To Round a Numeric Value To a Specific Precision in SQL Server Transact-SQL? Sometimes you need ...
What are single-byte character string data types supported in SQL Server Transact-SQL? Single-byte c...
How To Break Query Output into Pages in MySQL? If you have a query that returns hundreds of rows, an...
How To Locate and Take Substrings with CHARINDEX() and SUBSTRING() Functions in SQL Server Transact-...
How Fixed Length Strings Are Truncated and Padded in SQL Server Transact-SQL? When the length of the...