文章目录 秒数分钟小时天数 秒数 两个时间戳之间相减得到的就是秒数。 示例: select unix_timestamp("2022-11-08 14:00:00") - unix_timestamp("2022-11-08
两个时间戳之间相减得到的就是秒数。
示例:
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
来源地址:https://blog.csdn.net/weixin_46389691/article/details/127749468
--结束END--
本文标题: 在 SQL 中计算两个时间戳相隔的天时分秒
本文链接: https://www.lsjlt.com/news/379430.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-28
2024-04-28
2024-04-28
2024-04-28
2024-04-28
2024-04-28
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0