MONTH Function

Description

The MONTH function returns the month in the range of 1 to 12 from specified argument. You can specify the DATE, TIMESTAMP, or DATETIME type; the value is returned in INTEGER type.

0 is not allowed in the argument value corresponding to year, month, and day; however, if 0 is inputted in every argument value corresponding to date, 0 is returned as an exception.

Syntax

MONTH(date)

Example

SELECT MONTH('2010-01-02');

   month('2010-01-02')

======================

                     1

 

SELECT MONTH('2010-01-02 12:34:56');

   month('2010-01-02 12:34:56')

===============================

                              1

 

SELECT MONTH('2010-01-02 12:34:56.7890');

   month('2010-01-02 12:34:56.7890')

====================================

                                   1

 

SELECT MONTH ('12:34:56');

ERROR: Conversion error in date format.

 

SELECT MONTH('0000-00-00');

   month('0000-00-00')

======================

                     0