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, 1042🔥, 0💬
Popular Posts:
Why I Can Not Enter 0.001 Second in DATETIME values in SQL Server Transact-SQL? If you enter millise...
Where to find answers to frequently asked questions on Downloading and Installing SQL Server 2005 Ex...
How To Find Out What Privileges a User Currently Has in Oracle? Privileges granted to users are list...
What Is an Oracle Instance in Oracle? Every running Oracle database is associated with an Oracle ins...
Where to find answers to frequently asked questions on Storage Engines: MyISAM, InnoDB and BDB in My...