3

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.

Vipin Sahu
  • 1,441
  • 1
  • 18
  • 29
  • Take a look at this link: http://stackoverflow.com/questions/6427672/time-difference-between-query-result-rows-how-to – Thinhbk Jun 27 '12 at 07:57
  • thanks i tried but it was giving only second in difference , I tried as SELECT strftime('%M','now','localtime')-strftime('%M','2012-06-27 13:50:00','localtime') but it does not too – Vipin Sahu Jun 27 '12 at 08:24
  • Try this link: http://stackoverflow.com/questions/289680/difference-between-2-dates-in-sqlite – Thinhbk Jun 27 '12 at 09:50
  • thanks it does not work the way i m looking select datetime((julianday(datetime('now')))-julianday(datetime('2012-06-28 13:18:00'))) – Vipin Sahu Jun 28 '12 at 07:51

0 Answers0