{"id":241,"date":"2011-01-09T12:56:35","date_gmt":"2011-01-09T12:56:35","guid":{"rendered":"https:\/\/greladesign.co\/blog\/?p=241"},"modified":"2011-01-09T12:57:27","modified_gmt":"2011-01-09T12:57:27","slug":"sqlite-calculate-difference-between-datetime-fields","status":"publish","type":"post","link":"https:\/\/greladesign.co\/blog\/2011\/01\/09\/sqlite-calculate-difference-between-datetime-fields\/","title":{"rendered":"SQLite: Calculate difference between datetime fields"},"content":{"rendered":"<p>If you want to easily get elapsed time between datetime fields in SQLite you may want to take a look at following snippet:<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\n\r\nSELECT\r\ncast(\r\n         (\r\n                  strftime('%s',t.finish)-strftime('%s',t.start)\r\n         ) AS real\r\n      )\/60\/60 AS elapsed\r\nFROM some_table AS t;\r\n\r\n\r\n<\/pre>\n<p>Table <em>some_table<\/em> contains 2 columns named <em>start <\/em>and <em>finish <\/em>both <em>datetime<\/em> type. Result will contain value in hours.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you want to easily get elapsed time between datetime fields in SQLite you may want to take a look at following snippet: Table some_table contains 2 columns named start and finish both datetime type. Result will contain value in &hellip; <a href=\"https:\/\/greladesign.co\/blog\/2011\/01\/09\/sqlite-calculate-difference-between-datetime-fields\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":""},"categories":[17,9,58],"tags":[12,65,301,66,54,64],"_links":{"self":[{"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/posts\/241"}],"collection":[{"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/comments?post=241"}],"version-history":[{"count":9,"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/posts\/241\/revisions"}],"predecessor-version":[{"id":250,"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/posts\/241\/revisions\/250"}],"wp:attachment":[{"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/media?parent=241"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/categories?post=241"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/tags?post=241"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}