Skip to content

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

func.to_year(<expr>)
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.89516620242024
└───────────────────────────────────────────────────────────────────────────────┘
TO_YEAR(<expr>)
ArgumentsDescription
<expr>date/timestamp

SMALLINT

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