计算通话时长

发布于 2024-10-06 08:35:34 字数 141 浏览 10 评论 0原文

我在电信工作,我需要计算通话的通话时长。问题是我们有世界时间 24 小时(00:00:00 - 23:59:59)例如,现在通话从 22:31:40 开始并于 00:22:56 结束 现在我需要计算这次通话的持续时间。我可以知道计算它的逻辑吗

提前致谢

i am working for telecom,i need to calculate call duration of a call.the issue is we have world time 24hrs(00:00:00 - 23:59:59)for example, now the call starts at 22:31:40 and ends at 00:22:56
now i need to calculate the duration of this call. can i know the logic to calculate it

Thanks In advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

绝不放开 2024-10-13 08:35:34

DB2 没有内置函数可以执行此操作。但是,DB2 DATE 文档 包含用户定义的函数,它使用 DAYS() 和 MIDNIGHT_SECONDS() 来实现所需的结果。

CREATE FUNCTION secondsdiff(t1 TIMESTAMP, t2 TIMESTAMP) 
RETURNS INT 
RETURN ( 
    (DAYS(t1) - DAYS(t2)) * 86400 + 
    (MIDNIGHT_SECONDS(t1) - MIDNIGHT_SECONDS(t2)) 
) 
@ 

There is no DB2 built-in function to do this. However, the DB2 DATE documentation includes the source for a user-defined function which employs DAYS() and MIDNIGHT_SECONDS() to achieve the required result.

CREATE FUNCTION secondsdiff(t1 TIMESTAMP, t2 TIMESTAMP) 
RETURNS INT 
RETURN ( 
    (DAYS(t1) - DAYS(t2)) * 86400 + 
    (MIDNIGHT_SECONDS(t1) - MIDNIGHT_SECONDS(t2)) 
) 
@ 
权谋诡计 2024-10-13 08:35:34

第二次加上 24 小时,然后从第一次减去。如果结果大于 24 小时,则取出 24 小时。这显然不能处理超过 24 小时的呼叫,但我们假设它们不是。

...或者使用一些我不知道的 DB2 函数。

Add 24 hours to the second time and subtract from the first. If the result is greater than 24 hours, take the 24 back out. This obviously doesn't handle calls that ARE over 24 hours, but we'll assume they arent.

... or use some DB2 function I'm unaware of.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文