May 8

Calculating Difference (diff) between Date and Time using SQLite


To calculate difference between dates and time using SQLite database, you can use this SQL below:

.
.

1
SELECT cast((strftime('%s','now') - strftime('%s','2008-05-08 18:00:00')) AS 'float') / 60 AS minutes

or

1
SELECT cast((strftime('%s','now') - strftime('%s',tablefield)) AS 'float') / 60 AS minutes FROM TABLE

Note: use cast..float for more accurate results.

;)