当前位置:首页 » 编程语言 » 时间差sql

时间差sql

发布时间: 2024-12-08 03:11:34

sql求时间差,精确到秒分时

多行记录做这样的时间差值计算思路:

  1. 要将签入和签出配对处理,然后才能求出时间差值

  2. 或使用隐式游标进行处理,可以求出上一行记录和下一行记录的时间差值,但SQL语句极其晦涩难懂。

SQL计算秒的差值为:

selectdatediff(ss,'2019-01-0102:03:04',getdate())

㈡ sql 计算时间差得到时分秒。

declare @starttime as datetime
declare @endtime as datetime
set @starttime = '2009-11-21 00:00:00'
set @endtime = '2009-11-24 15:12:24'select right('00'+ cast(cast(datediff(ss ,@starttime,@endtime) / 3600 as int) as varchar),2) + ':' +
right('00'+ cast(cast(datediff(ss ,@starttime,@endtime) % 3600 / 60 as int) as varchar),2) + ':' +
right('00'+ cast(cast(datediff(ss ,@starttime,@endtime) % 60 as int) as varchar),2) as 时间差
时间差
--------------
87:12:24(1 行受影响)

热点内容
java返回this 发布:2025-10-20 08:28:16 浏览:585
制作脚本网站 发布:2025-10-20 08:17:34 浏览:881
python中的init方法 发布:2025-10-20 08:17:33 浏览:574
图案密码什么意思 发布:2025-10-20 08:16:56 浏览:761
怎么清理微信视频缓存 发布:2025-10-20 08:12:37 浏览:677
c语言编译器怎么看执行过程 发布:2025-10-20 08:00:32 浏览:1005
邮箱如何填写发信服务器 发布:2025-10-20 07:45:27 浏览:250
shell脚本入门案例 发布:2025-10-20 07:44:45 浏览:108
怎么上传照片浏览上传 发布:2025-10-20 07:44:03 浏览:799
python股票数据获取 发布:2025-10-20 07:39:44 浏览:705