MySQL Tutorial MySQL Advanced MySQL Database Account Management MySQL References

MySQL MONTHNAME() Function



The MySQL MONTHNAME() function returns the full name of the month (January, February, ... December) of a given date or datetime value.

Syntax

MONTHNAME(datetime)

Parameters

datetime Required. Specify a date or datetime value from which to extract the full month name.

Return Value

Returns the full name of the month of a given date or datetime value.

Example 1:

The example below shows the usage of MONTHNAME() function.

mysql> SELECT MONTHNAME('2018-08-18');
Result: 'August'

mysql> SELECT MONTHNAME('2018-08-18 10:38:42');
Result: 'August'

mysql> SELECT MONTHNAME('2018-08-18 10:38:42.000004');
Result: 'August'

mysql> SELECT MONTHNAME('2014-10-25');
Result: 'October'

mysql> SELECT MONTHNAME(CURDATE());
Result: 'November'

Example 2:

Consider a database table called Orders with the following records:

OrderQuantityPriceOrderTime
1001.582017-08-18 10:38:42
1201.612018-03-23 07:14:16
1251.782018-09-12 05:25:56
501.802019-01-16 11:52:05
2001.722020-02-06 09:31:34

The statement given below can be used to get the full name of the month of records of column OrderTime:

SELECT *, MONTHNAME(OrderTime) AS MONTHNAME_Value FROM Orders;

This will produce the result as shown below:

OrderQuantityPriceOrderTimeMONTHNAME_Value
1001.582017-08-18 10:38:42August
1201.612018-03-23 07:14:16March
1251.782018-09-12 05:25:56September
501.802019-01-16 11:52:05January
2001.722020-02-06 09:31:34February

❮ MySQL Functions