What is MONTH() in SQL?

The MONTH() function returns the month from a date sent as a parameter.

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

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

Syntax

MONTH(date)

Parameter

The MONTH() 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 MONTH() function returns the month from a date sent as a parameter.

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

Example

The following example shows how we can isolate the month from the admission dates of students using the MONTH() 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 *, MONTH(studentAdmissionDate) as MONTH
from Students;

Free Resources