TO_YEAR (Lakehouse v1)
Converts a date or date with time (timestamp/datetime) to a UInt16 number containing the year number (AD).
Analyze Syntax
Section titled “Analyze Syntax”func.to_year(<expr>)Analyze Examples
Section titled “Analyze Examples”func.now(), func.to_year(func.now()), func.year(func.now())
┌───────────────────────────────────────────────────────────────────────────────┐│ func.now() │ func.to_year(func.now()) │ func.year(func.now()) │├────────────────────────────┼──────────────────────────┼───────────────────────┤│ 2024-03-14 23:37:03.895166 │ 2024 │ 2024 │└───────────────────────────────────────────────────────────────────────────────┘SQL Syntax
Section titled “SQL Syntax”TO_YEAR(<expr>)Arguments
Section titled “Arguments”| Arguments | Description |
|---|---|
<expr> | date/timestamp |
Aliases
Section titled “Aliases”Return Type
Section titled “Return Type”SMALLINT
SQL Examples
Section titled “SQL Examples”SELECT NOW(), TO_YEAR(NOW()), YEAR(NOW());
┌───────────────────────────────────────────────────────────┐│ now() │ to_year(now()) │ year(now()) │├────────────────────────────┼────────────────┼─────────────┤│ 2024-03-14 23:37:03.895166 │ 2024 │ 2024 │└───────────────────────────────────────────────────────────┘