📣
TiDB Cloud Premium is now in public preview. Unlimited growth, instant elasticity, advanced security for enterprise workloads. Try it out →

TO_MONTH



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

Syntax

TO_MONTH(<expr>)

Arguments

ArgumentsDescription
<expr>date/timestamp

Aliases

Return Type

TINYINT

Examples

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

Was this page helpful?