Difference in seconds between timestamps in Sqlite3

前端 未结 2 1418
[愿得一人]
[愿得一人] 2020-12-06 05:51

Is it possible to get the difference (in seconds) between two TIMESTAMP values in Sqlite3?

For instance, I\'ve tried the following query:

SELECT CUR         


        
2条回答
  •  無奈伤痛
    2020-12-06 06:34

    Got it:

    SELECT (julianday(CURRENT_TIMESTAMP) - julianday(my_timestamp)) * 86400.0) FROM my_table;
    

    julianday returns the fractional number of days since noon in Greenwich on November 24, 4714 B.C. I then take the difference and multiply by the number of seconds per day.

提交回复
热议问题