两个时间戳之间相减得到的就是秒数。
示例:
select unix_timestamp("2022-11-08 14:00:00") - unix_timestamp("2022-11-08 13:00:00");
输出结果为:3600
两个时间戳相减的值除以 60 得到的就是分钟。
示例:
select (unix_timestamp("2022-11-08 15:00:00") - unix_timestamp("2022-11-08 13:00:00")) / 60;
输出结果为:120.0
两个时间戳相减的值除以 3600 得到的就是小时。
示例:
select (unix_timestamp("2022-11-08 17:00:00") - unix_timestamp("2022-11-08 13:00:00")) / 3600;
输出结果为:4.0
两个时间戳相减的值除以 3600 * 24 得到的就是天数。
示例:
select cast((unix_timestamp("2022-11-09 17:00:00") - unix_timestamp("2022-11-08 13:00:00")) / (3600 * 24) as int);
输出结果为:1