Menu

MySQL MONTHNAME() Function

Updated on

MySQL MONTHNAME(date) returns the month name for a date or datetime expression. The language is controlled by the lc_time_names session variable.

MONTHNAME() Syntax

Here is the syntax of MySQL MONTHNAME() function:

MONTHNAME(date)

Parameters

date
Required. A date or datetime expression.

Return value

The MySQL MONTHNAME() function returns the name of the month for a given date. MONTHNAME() will return a value that is one of the following: January, February, March, April, May, June, July, August, September, October, November, December.

  • If the specified expression is not a valid date or datetime, the MONTHNAME() function will return NULL.
  • If the argument is NULL, the MONTHNAME() function will return NULL.

The default lc_time_names value is en_US, regardless of the operating system locale. Set the session variable when month names should use another supported language. MySQL’s DATE_FORMAT() can also return a full (%M) or abbreviated (%b) month name.

MONTHNAME() Examples

Here are some examples of the MONTHNAME() function.

SELECT
    MONTHNAME('2021-01-01'),
    MONTHNAME('2021-02-01'),
    MONTHNAME('2021-03-01'),
    MONTHNAME('2021-04-01'),
    MONTHNAME('2021-05-01'),
    MONTHNAME('2021-06-01'),
    MONTHNAME('2021-07-01'),
    MONTHNAME('2021-08-01'),
    MONTHNAME('2021-09-01'),
    MONTHNAME('2021-10-01'),
    MONTHNAME('2021-11-01'),
    MONTHNAME('2021-12-01'),
    MONTHNAME('Not A DATE'),
    MONTHNAME(NULL)\G
MONTHNAME('2021-01-01'): January
MONTHNAME('2021-02-01'): February
MONTHNAME('2021-03-01'): March
MONTHNAME('2021-04-01'): April
MONTHNAME('2021-05-01'): May
MONTHNAME('2021-06-01'): June
MONTHNAME('2021-07-01'): July
MONTHNAME('2021-08-01'): August
MONTHNAME('2021-09-01'): September
MONTHNAME('2021-10-01'): October
MONTHNAME('2021-11-01'): November
MONTHNAME('2021-12-01'): December
MONTHNAME('Not A DATE'): NULL
        MONTHNAME(NULL): NULL

To return the name of the current month, pass CURDATE() to MONTHNAME():

SELECT MONTHNAME(CURDATE()) AS current_month;

Note that your results may vary.