Skip to content

Convert a date or date with time (timestamp/datetime) to a UInt8 number containing the month number (1-12).

func.to_month(<expr>)
func.now(), func.to_month(func.now()), func.month(func.now())
┌─────────────────────────────────────────────────────────────────────────────────┐
│ func.now() │ func.to_month(func.now()) │ func.month(func.now()) │
├────────────────────────────┼───────────────────────────┼────────────────────────┤
2024-03-14 23:34:02.16129133
└─────────────────────────────────────────────────────────────────────────────────┘
TO_MONTH(<expr>)
ArgumentsDescription
<expr>date/timestamp

TINYINT

SELECT NOW(), TO_MONTH(NOW()), MONTH(NOW());
┌─────────────────────────────────────────────────────────────┐
now() │ to_month(now()) │ month(now()) │
├────────────────────────────┼─────────────────┼──────────────┤
2024-03-14 23:34:02.16129133
└─────────────────────────────────────────────────────────────┘