Skip to main content

toMonth

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

Syntax

toMonth(expr)

Arguments

ArgumentsDescription
exprdate16/date32/datetime

Return Type

UInt8 datatype.

Examples

mysql> select toMonth(toDate(18869));
+------------------------+
| toMonth(toDate(18869)) |
+------------------------+
| 8 |
+------------------------+

mysql> select toMonth(toDateTime(1630812366));
+---------------------------------+
| toMonth(toDateTime(1630812366)) |
+---------------------------------+
| 9 |
+---------------------------------+