SQlite Time Difference using function strftime and date and using trigger to update on insert

倖福魔咒の 提交于 2019-12-10 18:12:22

问题


I want to have the difference between two timestamps, like

Endtime = strftime('%Y-%m-%d %H:%M:%S','now','localtime') 
firsttime = strftime('%Y-%m-%d %H:%M:%S','2012-01-27 02:34:56')

i.e. if my firsttime is 2012-06-15 14:54:33 and Endtime is 2012-06-15 14:54:40 then time diff would be like this =00:00:14;

I want to have such difference between timestamps, like Endtime-firsttime

I also want to use trigger to do use in SQLite database in Android.

In SQL we can do it by means of converting using the time to second function and second to time functions.

Any suggestion would be appreciated, however I can get time differences in Java easily but my application has lots of other work. So I wish I could achieve the same using a SQLite built-in function so the burden on the application becomes less.

来源:https://stackoverflow.com/questions/11221509/sqlite-time-difference-using-function-strftime-and-date-and-using-trigger-to-upd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!