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.