TO_YEAR (Lakehouse v1)
Converte uma data ou data com hora (timestamp/datetime) em um número UInt16 que contém o número do ano (d.C.).
Sintaxe do Analyze
Seção intitulada “Sintaxe do Analyze”func.to_year(<expr>)Exemplos do Analyze
Seção intitulada “Exemplos do Analyze”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 │└───────────────────────────────────────────────────────────────────────────────┘Sintaxe SQL
Seção intitulada “Sintaxe SQL”TO_YEAR(<expr>)Argumentos
Seção intitulada “Argumentos”| Argumentos | Descrição |
|---|---|
<expr> |
data/timestamp |
Aliases
Seção intitulada “Aliases”Tipo de retorno
Seção intitulada “Tipo de retorno”SMALLINT
Exemplos de SQL
Seção intitulada “Exemplos de SQL”SELECT NOW(), TO_YEAR(NOW()), YEAR(NOW());
┌───────────────────────────────────────────────────────────┐│ now() │ to_year(now()) │ year(now()) │├────────────────────────────┼────────────────┼─────────────┤│ 2024-03-14 23:37:03.895166 │ 2024 │ 2024 │└───────────────────────────────────────────────────────────┘