totn MariaDB Functions

MariaDB: DAYOFWEEK Function

This MariaDB tutorial explains how to use the MariaDB DAYOFWEEK function with syntax and examples.

Description

The MariaDB DAYOFWEEK function returns the weekday index for a date value.

Syntax

The syntax for the DAYOFWEEK function in MariaDB is:

DAYOFWEEK( date_value )

Parameters or Arguments

date_value
A date or datetime value from which to extract the weekday index.

Note

  • The DAYOFWEEK function returns the weekday index where 1=Sunday, 2=Monday, 3=Tuesday, 4=Wednesday, 5=Thursday, 6=Friday, 7=Saturday.

Applies To

The DAYOFWEEK function can be used in the following versions of MariaDB:

  • MariaDB 10

Example

Let's look at some MariaDB DAYOFWEEK function examples and explore how to use the DAYOFWEEK function in MariaDB.

For example:

SELECT DAYOFWEEK('2014-05-19');
Result: 2

SELECT DAYOFWEEK('2014-05-20');
Result: 3

SELECT DAYOFWEEK('2014-05-21');
Result: 4

This last DAYOFWEEK example would display the weekday index for the current system date (current system date is returned by the CURDATE function).

SELECT DAYOFWEEK(CURDATE());