MySQL DAYNAME() Function

The DAYNAME() function in MySQL retrieves the name of the day of the week for a given date. This is incredibly useful for presenting dates in a more user-friendly format, or for filtering and sorting data based on days of the week.



DAYNAME(): Definition and Usage

Unlike functions that return a numerical representation of the day (like 1 for Sunday, 2 for Monday), DAYNAME() returns the full textual name of the day (e.g., "Sunday", "Monday"). This makes your queries more readable and improves the presentation of your results.

Syntax

Syntax

DAYNAME(date)
      

Parameter Values

Parameter Description
date The date value (or datetime) from which you want to extract the day name. This is required.

Examples

Getting the Day Name for a Specific Date

This query retrieves the day name for June 15th, 2017.

Syntax

SELECT DAYNAME("2017-06-15");
      
Output

Thursday
      

Getting the Day Name from a DateTime Value

This example shows that DAYNAME() works equally well with datetime values.

Syntax

SELECT DAYNAME("2017-06-15 09:34:21");
      
Output

Thursday
      

Getting the Day Name for Today

This query returns the name of the current day.

Syntax

SELECT DAYNAME(CURDATE());
      
Output

(The name of the current day, e.g., Sunday, Monday, etc.)