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, 908🔥, 0💬
Popular Posts:
How To Disable a Login Name in SQL Server? If you want temporarily disable a login name, you can use...
How To Verify Your PHP Installation in MySQL? PHP provides two execution interfaces: Command Line In...
How To Generate Random Numbers with the RAND() Function in SQL Server Transact-SQL? Random numbers a...
What is test testing area for? The testing area is provided to allow visitors to post testing commen...
How To Verify a User name with SQLCMD Tool in SQL Server? The quickest way to verify a user name in ...