SQLite: express the difference as days, hours, minutes between two given dates

前端 未结 1 503
遥遥无期
遥遥无期 2020-12-10 05:50

I am trying to express the difference of two given dates in days, hours, and minutes (like 1 day, 6 hours, 17 minutes.) as SQLite query output. I have entryin a

相关标签:
1条回答
  • 2020-12-10 06:51

    You can try something like this:

    SELECT
        CAST((strftime('%s', '2011-11-10 11:46') - strftime('%s', '2011-11-09 09:00')) / (60 * 60 * 24) AS TEXT) || ' ' ||
        CAST(((strftime('%s', '2011-11-10 11:46') - strftime('%s', '2011-11-09 09:00')) % (60 * 60 * 24)) / (60 * 60) AS TEXT) || ':' ||
        CAST((((strftime('%s', '2011-11-10 11:46') - strftime('%s', '2011-11-09 09:00')) % (60 * 60 * 24)) % (60 * 60)) / 60 AS TEXT);
    
    0 讨论(0)
提交回复
热议问题