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:

.
.

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

or

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

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

;)


Outras postagens interessantes

Deixe o seu comentário

Você pode usar as seguintes tags no seu comentário: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="">

Para comentar um código, utilize por exemplo: <pre lang="php" line="2">echo 'Hello World';</pre>