Collections:
WEEKDAY() - Weekday (0=Monday)
How to calculate the weekday index from a given date using the WEEKDAY() function?
✍: FYIcenter.com
WEEKDAY(date) is a MySQL built-in function that
returns the weekday index from a given date.
For example:
SELECT WEEKDAY(NOW()), DAYOFWEEK(NOW()), DAYNAME(NOW()), NOW(); -- +----------------+------------------+----------------+---------------------+ -- | WEEKDAY(NOW()) | DAYOFWEEK(NOW()) | DAYNAME(NOW()) | NOW() | -- +----------------+------------------+----------------+---------------------+ -- | 3 | 5 | Thursday | 2023-11-16 08:05:56 | -- +----------------+------------------+----------------+---------------------+
Reference information of the WEEKDAY() function:
WEEKDAY(date): int Returns the weekday index for date (0 = Monday, 1 = Tuesday, … 6 = Sunday). Arguments, return value and availability: date: Required. The date to extract the weekday index from. int: Return value. The weekday index. Available since MySQL 4.
Related MySQL functions:
⇒ WEEKOFYEAR() - Calendar Week of Year
2023-11-16, 1454🔥, 0💬
Popular Posts:
How To Revise and Re-Run the Last SQL Command in Oracle? If executed a long SQL statement, found a m...
How To List All User Names in a Database in SQL Server? If you want to see a list of all user names ...
How To Connect to a MySQL Server with a Port Number in MySQL? If you want to connect a MySQL server ...
What Are the Differences between DATE and TIMESTAMP in Oracle? The main differences between DATE and...
How To Fix the INSERT Command Denied Error in MySQL? The reason for getting the "1142: INSERT comman...