SQLite: Calculate difference between datetime fields

If you want to easily get elapsed time between datetime fields in SQLite you may want to take a look at following snippet:


SELECT
cast(
         (
                  strftime('%s',t.finish)-strftime('%s',t.start)
         ) AS real
      )/60/60 AS elapsed
FROM some_table AS t;


Table some_table contains 2 columns named start and finish both datetime type. Result will contain value in hours.

This entry was posted in actionscript, flash, SQLite3 (in AIR) and tagged , , , , , . Bookmark the permalink.

1 Response to SQLite: Calculate difference between datetime fields

  1. Shanta Scheibelhut says:

    nice post you got here. thanks for the inspiration

Comments are closed.