MONTHNAME() : Full Month name in MySQL

Returns full month name from a date.
Syntax
MONTHNAME()
Example :
SELECT MONTHNAME('2016-09-25') 
Output is September

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 December

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
NovemberDecemberJanuary

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; 
?>
Visitors Rating
Your Rating




Google+

Post Comment This is for short comments only. Use the forum for more discussions.








HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us
©2000-2018 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer