MONTH

The MONTH function returns the month part of a value.

Syntax

MONTH ( expression )

expression

An expression that can be a time, timestamp, or a valid character string representation of a time or timestamp.

Results

The returned result is an integer value in the range 1 to 12.

If the argument can be NULL, the result can be NULL; if the argument is NULL, the result is the NULL value.

Examples

Get the current date:

splice> VALUES(CURRENT_DATE);
1
--------
2014-05-15

Now get the current month only:

splice> VALUES(MONTH(CURRENT_DATE));
1
--------
5

Get the month of one week from now:

splice> VALUES(MONTH(CURRENT_DATE+7));
1
--------
5

Select all players who were born in December:

splice> SELECT DisplayName, Team, BirthDate
   FROM Players
   WHERE MONTH(BirthDate)=12;
DISPLAYNAME             |TEAM      |BIRTHDATE
----------------------------------------------
Greg Brown              |Giants    |1983-12-24
Reed Lister             |Giants    |1986-12-16
Cameron Silliman        |Cards     |1988-12-21
Edward Erdman           |Cards     |1985-12-21
Taylor Trantula         |Cards     |1987-12-17
Tam Croonster           |Cards     |1980-12-19

6 rows selected

See Also