MariaDB Tutorial MariaDB Advanced MariaDB Database Account Management MariaDB References

MariaDB DAYNAME() Function



The MariaDB DAYNAME() function returns the weekday name (Sunday, Monday, Tuesday, etc.) of a given date or datetime value.

Syntax

DAYNAME(datetime)

Parameters

datetime Required. Specify a date or datetime value from which to extract the weekday name.

Return Value

Returns the weekday name of a given date or datetime value.

Return Value

Returns the weekday name of a given date or datetime value.

Example 1:

The example below shows the usage of DAYNAME() function.

SELECT DAYNAME('2018-08-18');
Result: 'Saturday'

SELECT DAYNAME('2018-08-18 10:38:42');
Result: 'Saturday'

SELECT DAYNAME('2018-08-18 10:38:42.000004');
Result: 'Saturday'

SELECT DAYNAME('2014-10-20');
Result: 'Monday'

SELECT DAYNAME(CURDATE());
Result: 'Wednesday'

Example 2:

Consider a database table called Orders with the following records:

OrderQuantityPriceOrderTime
1001.582017-08-18 10:38:42
1201.612018-03-23 07:14:16
1251.782018-09-12 05:25:56
501.802019-01-16 11:52:05
2001.722020-02-06 09:31:34

The statement given below can be used to get the weekday name of records of column OrderTime:

SELECT *, DAYNAME(OrderTime) AS DAYNAME_Value FROM Orders;

This will produce the result as shown below:

OrderQuantityPriceOrderTimeDAYNAME_Value
1001.582017-08-18 10:38:42Friday
1201.612018-03-23 07:14:16Friday
1251.782018-09-12 05:25:56Wednesday
501.802019-01-16 11:52:05Wednesday
2001.722020-02-06 09:31:34Thursday

❮ MariaDB Functions