SQL MONTHNAME() Function
The SQL MONTHNAME() is a function, and returns a string indicating the full name of the specified month of a given input date value.
The SQL MONTHNAME() function is supports only date or datetime based table columns or fields.
It can be used in SELECT statement as well in where clause.
Related Links
SQL MONTHNAME() Syntax
The below syntax is used to extract full name of the specified month from given a input date value.
For SQL SERVER / MY SQL
SELECT MONTHNAME('valid_date_value');
For MS Access
SELECT MONTHNAME(valid_integer_number);
SQL MONTHNAME() Example - Using Expression Or Formula
The following SQL SELECT statement will extract full name of the specified month from a given input date value. We use now() function to get the input date value.
For SQL SERVER / MY SQL
SELECT
NOW() AS 'Current Date and Time',
MONTHNAME(NOW()) AS 'Month Name';
For MS Access
SELECT
NOW() AS 'Current Date and Time',
MONTHNAME(MONTH(NOW())) AS 'Month Name';
Note: the MONTH() function returns a integer specifying a whole number between 1 and 12, inclusive, representing the month of the year.
The result of above query is:
Current Date and Time | Month Name |
---|---|
16-06-2013 15:48:52 | June |
Sample Database Table - BookOrder
BookID | BookName | OrderDate |
---|---|---|
1 | Professional Microsoft SQL Server | 13-03-2008 03:53:18 |
2 | SQL Server All-in-One For Dummies | 16-02-2004 05:15:53 |
3 | Programming with PL/SQL for Beginners | 12-05-2007 02:15:56 |
4 | Natural language Query To SQL | 13-06-2009 23:44:18 |
SQL MONTHNAME() Example - With Table Column
The following SQL SELECT statement display the column "OrderDate", from the "BookOrder" table. The MONTHNAME() function will extract the fullname of the specified month from the column "OrderDate" and we will stored that value to a new column called "Month Name From OrderDate".
For SQL SERVER / MY SQL
SELECT OrderDate,
MONTHNAME(OrderDate) As 'Month Name From OrderDate'
FROM BookOrder;
For MS Access
SELECT OrderDate,
MONTHNAME(MONTH(OrderDate)) AS 'Month Name From OrderDate'
FROM BookOrder;
The result of above query is:
OrderDate | Month Name From OrderDate |
---|---|
13-03-2008 03:53:18 | March |
16-02-2004 05:15:53 | February |
12-05-2007 02:15:56 | May |
13-06-2009 23:44:18 | June |
Related Links