两个时间戳之间的 30 分钟间隔数

Number of 30 min intervals between two timestamps

每一行数据都有一个开始和结束时间戳。我使用 time_slice 函数将它们四舍五入到最接近的 30 分钟间隔。现在,我想计算开始和结束之间的 30 分钟间隔数(对于每一行)。是否有某种内置函数,或者我需要先将其转换为 epoch/unix。

select '01:30'::time as a,
   '13:30'::time as b, 
   timediff('min',a,b) as c, 
   floor(c/30) as d;

给出:

A B C D
01:30:00 13:30:00 720 24

所以我会使用 TIMEDIFF or DATEDIFF and FLOOR 除法。