Reputation: 1729
I have a table with a start and end time like so
stime | etime
12:00 | 13:20
i now have to add a third column with the duration
stime | etime | durationMins
12:00 | 13:20 | 80
I have this to get my duration in minutes
SELECT TIME_TO_SEC(TIMEDIFF(stime , etime))/60 AS MinuteDiff
FROM mytable
MinuteDiff now contains my minutes, how can I update durationMins for all rows based on the above select?
Upvotes: 1
Views: 46
Reputation: 474
Assuming that you have the durationMins column already created
UPDATE Table_name
set durationMins = TIME_TO_SEC(TIMEDIFF(stime , etime))/60 AS MinuteDiff
This should work.
Upvotes: 2