MONTH returns the month portion of a value.

Syntax

MONTH ( expression )

Arguments

expression: a DATE, TIMESTAMP, or non-LONG VARCHAR string value that is properly formatted to represent a DATE or TIMESTAMP.

Returns

  • An INTEGER for the month, between 1 and 12. Returns NULL if expression is NULL.

Examples

SELECT orderDate, MONTH(orderDate) AS orderDateMonth FROM MYSQL.inventory.cust;

VALUES MONTH(CAST('2012-06-20 15:23:45' AS TIMESTAMP))
-- Returns 6