跳转到内容

将带时间的日期(timestamp/datetime)向下取整到整点开始时刻。

func.to_start_of_hour(<expr>)
func.to_start_of_hour('2023-11-12 09:38:18.165575')
┌────────────────────────────────────────────────────────────────┐
│ func.to_start_of_hour('2023-11-12 09:38:18.165575') │
│ Timestamp │
├────────────────────────────────────────────────────────────────┤
│ 2023-11-12 09:00:00 │
└────────────────────────────────────────────────────────────────┘
TO_START_OF_HOUR(<expr>)
参数 说明
<expr> 时间戳

TIMESTAMP,以“YYYY-MM-DD hh:mm:ss.ffffff”格式返回日期。

SELECT
to_start_of_hour('2023-11-12 09:38:18.165575')
┌────────────────────────────────────────────────┐
│ to_start_of_hour('2023-11-12 09:38:18.165575') │
│ Timestamp │
├────────────────────────────────────────────────┤
│ 2023-11-12 09:00:00 │
└────────────────────────────────────────────────┘