MySQL MONTHNAME() Function
In MySQL, the MONTHNAME() function returns the name of the month for a given date.
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 returnNULL. - If the argument is
NULL, theMONTHNAME()function will returnNULL.
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): NULLIf you want to return the name of the current month, use any NOW() of , CURDATE(), CURRENT_DATE(), SYSDATE() or . for example:
SELECT
MONTHNAME(NOW()),
MONTHNAME(CURDATE()),
MONTHNAME(CURRENT_DATE()),
MONTHNAME(SYSDATE())\G
MONTHNAME(NOW()): April
MONTHNAME(CURDATE()): April
MONTHNAME(CURRENT_DATE()): April
MONTHNAME(SYSDATE()): AprilNote that your results may vary.