MONTHNAME() : Full Month name in MySQL

SELECT MONTHNAME('2023-01-01'); # January
SELECT MONTHNAME('2023-12-31');# December
SELECT MONTHNAME('2023-02-31');# NULL
Returns full month name from a date.
Syntax
MONTHNAME()
Example :
SELECT MONTHNAME('2016-09-25') 
Output is September
DEMO: Select date from Calendar to execute MONTHNAME()

MONTHNAME() function to get full name of the month in MySQL

CURDATE() or NOW() & MONTHNAME()

By using CURDATE() we get the present date part only, where as by using NOW() we will get both date and time.
SELECT MONTHNAME(CURDATE())
Output is October

To get short month name as Jan, Feb ... you can use Date format.
SELECT date_format(date,'%b') as dt FROM table_name

Short Month

We can search for matching short months ( three digit month name) like Jan , Feb etc using WHERE condition.
SELECT * FROM `table_name` WHERE DATE_FORMAT(date, '%b')='Jan'

Full Month name

SELECT * FROM `table_name` WHERE DATE_FORMAT( date, '%M' ) = 'January'

Last Month , Today and Next Month

SELECT MONTHNAME(CURDATE()- interval 1 month)  as LastMonth, 
MONTHNAME(CURDATE()) as PresentMonth, 
MONTHNAME(CURDATE()+ interval 1 Month) as NextMonth
Last MonthPresentMonthNextMonth
SeptemberOctoberNovember

PHP Script

To display the above details we used PHP Script, you can use the same script for using all above queries.

config.php connection string is available here

PDO for executing Queries in PHP

How to get records using FETCH() are here

<?Php
require 'config.php';  // Database connection string
$query='SELECT MONTHNAME(NOW()) as dt';
// Change the above Query part to get different results // 

$count=$dbo->prepare($query);
$count->execute();
$row = $count->fetch(PDO::FETCH_OBJ);
echo 'Output is : '.$row->dt; 
?>
SQL Date MONTH() : Month number from 1 to 12
SQL txt file for MONTHNAME()
Subhendu Mohapatra — author at plus2net
Subhendu Mohapatra

Author

🎥 Join me live on YouTube

Passionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.



Subscribe to our YouTube Channel here



plus2net.com




SQL Video Tutorials










We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer