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

TO_YEAR



Converts a date or date with time (timestamp/datetime) to a UInt16 number containing the year number (AD).

Syntax

TO_YEAR(<expr>)

Arguments

ArgumentsDescription
<expr>date/timestamp

Aliases

Return Type

SMALLINT

Examples

SELECT NOW(), TO_YEAR(NOW()), YEAR(NOW()); ┌───────────────────────────────────────────────────────────┐ │ now() │ to_year(now()) │ year(now()) │ ├────────────────────────────┼────────────────┼─────────────┤ │ 2024-03-14 23:37:03.89516620242024 │ └───────────────────────────────────────────────────────────┘

Was this page helpful?