MySQL MONTHNAME Function

MySQL MONTHNAME function is one of the MySQL Date Functions, which returns the full name of the Month for a given date. This MySQL Monthname function gets the full name and returns January, February,.., December. The basic syntax of the Monthname Function is as shown below:

MONTHNAME(date or expression);

MySQL Monthname function Example

The below shown queries help you understand the use of this MySQL Month name function. Here, we are returning the name of the Month from the different date expression, and the Date & time expression.

SELECT MONTHNAME('2016-12-22');

SELECT MONTHNAME('2016-07-22 12:22:33');

SELECT NOW(), MONTHNAME(NOW());
MySQL MONTHNAME Function 1

MySQL Monthname Function Example 2

The following MySQL query shows you what happens when we try to return the month number from different date formats. In this Date Function example, we are trying to return the full name of a month from YYYYMMDD, YYMMDD, YYYYMMDDHHMMSS formats.

SELECT MONTHNAME('20170922');

SELECT MONTHNAME('750122');

SELECT MONTHNAME('19750622101434');
MySQL MONTHNAME Function 2

In this example, we are trying to return the full name of a month from an invalid date and zero month part. Within the last statement, we used the CURDATE() function inside the MONTHNAME and added 4 and 42.

SELECT MONTHNAME('1975-00-00');

SELECT MONTHNAME('750439');

SELECT MONTHNAME(CURDATE() + 4), MONTHNAME(CURDATE() + 42);
MySQL MONTHNAME Function 3