I’m trying to add a column called ride_length to my table to calculate the time difference between the started_at and ended_at columns with the query below but I’m not getting anywhere. What am I doing wrong?
ALTER TABLE total_tripdata ADD COLUMN ride_length AS (TIME(strftime(‘%s’,ended_at) – strftime(‘%s’,started_at), ‘unixepoch’))
started_at | ended_at |
---|---|
0023-07-10 04:57:00 UTC | 0023-07-10 05:00:00 UTC |
0023-10-15 01:36:00 UTC | 0023-10-15 01:50:00 UTC |
0023-10-21 01:17:00 UTC | 0023-10-21 01:27:00 UTC |
0023-08-08 19:00:00 UTC | 0023-08-08 19:02:00 UTC |
As stated above, I tried this query and got no where with the query.
ALTER TABLE total_tripdata ADD COLUMN ride_length AS (TIME(strftime(‘%s’,ended_at) – strftime(‘%s’,started_at), ‘unixepoch’))
I was hoping for a new column to show me the difference in time after subtracting the ended_at time from the started_at time.
Efrain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1