MariaDB: WEEKDAY Function
This MariaDB tutorial explains how to use the MariaDB WEEKDAY function with syntax and examples.
Description
The MariaDB WEEKDAY function returns the weekday index for a date.
Syntax
The syntax for the WEEKDAY function in MariaDB is:
WEEKDAY( date_value )
Parameters or Arguments
- date_value
- A date or datetime value from which to extract the weekday index.
Note
- The WEEKDAY function returns the index of the weekday (0=Monday, 1=Tuesday, 2=Wednesday, 3=Thursday, 4=Friday, 5=Saturday, 6=Sunday) given a date value.
- See also the DAYNAME function.
Applies To
The WEEKDAY function can be used in the following versions of MariaDB:
- MariaDB 10
Example
Let's look at some MariaDB WEEKDAY function examples and explore how to use the WEEKDAY function in MariaDB.
For example:
SELECT WEEKDAY('2014-05-19'); Result: 0 SELECT WEEKDAY('2014-05-20'); Result: 1 SELECT WEEKDAY('2014-05-21 11:22:17'); Result: 2
This last WEEKDAY example would display the weekday index for the current system date (current system date is returned by the CURDATE function).
SELECT WEEKDAY(CURDATE());
Advertisements