SQLite Forum

How can I calculate trip duration?
Login
>
   SELECT (julianday(ended_at)-julianday(started_at)) as duration FROM ...

The duration computed this way will be in days.  Multiply by 24.0 to get hours, 
or 86400.0 to get seconds, and so forth. Example:

> ~~~
SELECT (julianday('now') - julianday('2000-05-29 14:16')) AS duration;
┌──────────────────┐
│     duration     │
├──────────────────┤
│ 7724.33961798623 │
└──────────────────┘
SELECT (julianday('now') - julianday('2000-05-29 14:16'))*86400.0 AS 'duration in seconds';
┌─────────────────────┐
│ duration in seconds │
├─────────────────────┤
│ 667383060.794015    │
└─────────────────────┘
~~~

The SQLite project has been going for a little over 7724 days, or about 667
million seconds.