What is MONTHNAME() in SQL?

The MONTHNAME() function returns the name of the month from a date sent as a parameter.

Figure 1 shows a visual representation of the MONTHNAME() function and the month numbers.

Figure 1: Visual representation of MONTHNAME() function and the month numbers

Syntax

MONTHNAME(date)

Parameter

The MONTHNAME() function takes the date as a parameter.

Dates must be in the format YYYY-MM-DD, or else this function returns NULL.

Return value

The MONTHNAME() function returns the name of the month from a date sent as a parameter.

It returns NULL if the month part of the date is equal to 0 or greater than 12.

Example

The following example shows how we can get the month from the admission dates of students using the MONTHNAME() function.

Students

Student ID

Student Name

Student Admission Date

1

David

2000-07-14

2

Luiss

2002-08-15

3

Harvey

2005-04-19

4

Lucy

2010-01-27

5

Andrew

2011-10-03

SELECT *, MONTHNAME(studentAdmissionDate) as MonthName
from Students;
New on Educative
Learn any Language for FREE all September 🎉
For the entire month of September, get unlimited access to our entire catalog of beginner coding resources.
🎁 G i v e a w a y
30 Days of Code
Complete Educative’s daily coding challenge every day in September, and win exciting Prizes.

Free Resources