SQL Netezza - 如何将日期时间四舍五入到最近的小时

SQL Netezza - How to round datetime to nearest hour

我需要从下面的字段中获取如何将日期时间四舍五入到最近的小时

2019-09-29 13:05:42
2019-09-29 13:06:16
2019-09-29 13:04:43

您可以使用 date_trunc()。如果 "round" 你的意思是截断,那么有一个内置函数:

date_trunc('hour', col)

如果 "round" 你的意思是 "round",那么:

date_trunc('hour', col + interval '30 minute')