DAYOFWEEK() function in MySQL

DAYOFWEEK() function The MySQL DAYOFWEEK function extracts the weekday index from a date or datetime value. The various versions of MySQL support the DAYOFWEEK function, namely, MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, and MySQL 3.23.

Syntax:

DAYOFWEEK( expression )

Parameters:

expression: It is used to specify the date or datetime value.

Example 1:

mysql> SELECT DAYOFWEEK ('2019-07-05');

Output:

6

Explanation:

The weekday index has been extracted from the date value. Here, 6 is the weekday index for FRIDAY.

Example 2:

mysql> SELECT DAYOFWEEK ('2019-07-05 15:30:20');

Output:

6

Explanation:

The weekday index has been extracted from the datetime value. Here, 6 is the weekday index for FRIDAY.

Please follow and like us:
Content Protection by DMCA.com