MySQL MONTHNAME() Function

MySQL | MONTHNAME() Function: Learn about the MONTHNAME() function, how it works, its usages, syntax, and examples.
Submitted by Apurva Mathur, on October 10, 2022

MONTHNAME() Function

The MONTHNAME() function helps us to get the complete month name from any datetime value. It fetches the month name from the date and then displays it as a result.

MONTHNAME() Syntax

SELECT MONTHNAME('datetime value');

MONTHNAME() Parameter(s)

  • It takes only one parameter which is datetime value.

MONTHNAME() Return Value

As a result, it will display the name of the month from the given date/time that you have provided.

MySQL MONTHNAME() Function Example 1

SELECT MONTHNAME('2012-09-08');
Example 1: MySQL MONTHNAME() Function

MySQL MONTHNAME() Function Example 2

SELECT MONTHNAME('2022-04-09 12:09:08');
Example 2: MySQL MONTHNAME() Function

But if you will provide the date which is not valid then in such case it will show you NULL.

MySQL MONTHNAME() Function Example 3

SELECT MONTHNAME('2022-44-09');
Example 2: MySQL MONTHNAME() Function

In the above example, we can see that the month has 44 value which is not valid therefore it displays NULL.




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.