TO_MONTH(Lakehouse v1)
将日期或带时间的日期(timestamp/datetime)转换为包含月份编号(1-12)的 UInt8 数字。
Analyze 语法
Section titled “Analyze 语法”func.to_month(<expr>)Analyze 示例
Section titled “Analyze 示例”func.now(), func.to_month(func.now()), func.month(func.now())
┌─────────────────────────────────────────────────────────────────────────────────┐│ func.now() │ func.to_month(func.now()) │ func.month(func.now()) │├────────────────────────────┼───────────────────────────┼────────────────────────┤│ 2024-03-14 23:34:02.161291 │ 3 │ 3 │└─────────────────────────────────────────────────────────────────────────────────┘SQL 语法
Section titled “SQL 语法”TO_MONTH(<expr>)| 参数 | 说明 |
|---|---|
<expr> |
日期/时间戳 |
TINYINT
SQL 示例
Section titled “SQL 示例”SELECT NOW(), TO_MONTH(NOW()), MONTH(NOW());
┌─────────────────────────────────────────────────────────────┐│ now() │ to_month(now()) │ month(now()) │├────────────────────────────┼─────────────────┼──────────────┤│ 2024-03-14 23:34:02.161291 │ 3 │ 3 │└─────────────────────────────────────────────────────────────┘