MySQL MONTHNAME() Function

The MONTHNAME() function in MySQL retrieves the full name of the month from a given date value. This is very useful for presenting dates in a more user-friendly format or for filtering and sorting data based on month names.



MONTHNAME(): Definition and Usage

Instead of returning a number representing the month (like 1 for January, 2 for February), MONTHNAME() returns the full textual name of the month (e.g., "January", "February"). This makes your queries easier to read and understand, especially when displaying the results to end-users.

Syntax

Syntax

MONTHNAME(date)
      

Parameter Values

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

Examples

Extracting the Month Name from a Date

This example gets the name of the month for June 15th, 2017.

Syntax

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

June
      

Extracting the Month Name from a Datetime

This example shows that MONTHNAME() works correctly even with datetime values.

Syntax

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

June
      

Extracting the Current Month Name

Getting the name of the current month.

Syntax

SELECT MONTHNAME(CURDATE());
      
Output

(The current month's name, e.g., October)