跳转到内容

将指定数量的小时转换为 Interval 类型。

  • 接受正整数、零和负整数作为输入。
func.to_hours(<hours>)
func.to_hours(2)
┌──────────────────────────────────────────────────────┐
│ func.to_hours(2) │
├──────────────────────────────────────────────────────┤
│ 2:00:00 │
└──────────────────────────────────────────────────────┘
TO_HOURS(<hours>)

Interval(格式为 hh:mm:ss)。

SELECT TO_HOURS(2), TO_HOURS(0), TO_HOURS((- 2));
┌───────────────────────────────────────────┐
│ to_hours(2) │ to_hours(0) │ to_hours(- 2) │
├─────────────┼─────────────┼───────────────┤
│ 2:00:00 │ 00:00:00 │ -2:00:00 │
└───────────────────────────────────────────┘