HH:MM:SS格式的SQLite时差计算 [英] SQLite time difference calculations in HH:MM:SS format

查看:54
本文介绍了HH:MM:SS格式的SQLite时差计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在SQLite中以HH:MM:SS格式计算时差?

How to calculate time difference in HH:MM:SS format in SQLite?

SELECT time(strftime('%s','2017-11-01 22:25:28')-strftime('%s','2017-11-01'));给我:

12:00:00

12:00:00

SELECT datetime(strftime('%s','2017-11-01 22:25:28')-strftime('%s','2017-11-01'));给我:

-4492-12-04 12:00:00

-4492-12-04 12:00:00

推荐答案

文档中所述a>,默认情况下数字被解释为儒略日日期数字.

As documented in the documentation, numbers are interpreted as Julian date numbers by default.

如果您的值是秒数,则必须将其解释为秒数,即Unix时间戳:

If your value is a number of seconds, you have to interpret it as a number of seconds, i.e., as a Unix timestamp:

SELECT time(strftime('%s','2017-11-01 22:25:28') - strftime('%s','2017-11-01'), 'unixepoch');

这篇关于HH:MM:SS格式的SQLite时差计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆