Skip to main content

TO_MONTH

Converts a date or date with time to a UInt8 number containing the month number (1-12).

Syntax

to_month( <expr> )

Arguments

ArgumentsDescription
<expr>date/datetime

Return Type

UInt8 datatype.

Examples

SELECT to_month(to_date(18869));
+------------------------+
| to_month(to_date(18869)) |
+------------------------+
| 8 |
+------------------------+

SELECT to_month(to_datetime(1630812366));
+---------------------------------+
| to_month(to_datetime(1630812366)) |
+---------------------------------+
| 9 |
+---------------------------------+