DAY returns the day portion of a value.

Syntax


DAY(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 representing the day, between 1 and 31. Returns NULL when expression is NULL.

Examples


SELECT orderDate, DAY(orderDate) AS orderDateDay FROM MYSQL.inventory.cust;

VALUES DAY(CAST('2012-06-20' AS TIMESTAMP))
-- Returns 20

VALUES DAY(CAST('2012-06-03' AS TIMESTAMP))
-- Returns 3