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.


Search Keys

  • sql monthname function
  • sql server month name
  • sql get month name
  • sql datepart month name
  • sql server get month name from date
  • datepart month name
  • sql query month name
  • month name in sql
  • sql month from date
  • sql month function
  • sql get month
  • sql day of month

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
5 Troubleshooting SQL Server 22-01-1995 13:11:29
6 Simply SQL Server 19-02-2006 03:14:35
7 SQL and Relational Theory 25-01-2007 14:11:02
8 Oracle Database 11G New Features 23-02-2011 20:47:22
9 Securing SQL Server 13-10-2010 09:30:55
10 Oracle Database Internals 25-07-1996 01:47:37
11 A Visual Introduction To Sql 12-06-1996 23:47:41
12 MySql for professionals 14-06-1997 07:51:26

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
22-01-1995 13:11:29 January
19-02-2006 03:14:35 February
25-01-2007 14:11:02 January
23-02-2011 20:47:22 February
13-10-2010 09:30:55 October
25-07-1996 01:47:37 July
12-06-1996 23:47:41 June
14-06-1997 07:51:26 June

Search Keys

  • sql compare month
  • sql month format
  • sql month date
  • get month from date sql server
  • last day of month sql
  • sql last month
  • sql end of month
  • sql date month year
  • sql server datepart month
  • sql convert month
  • sql get current date
  • sql server date functions