How can I retrieve difference between two columns in time format?
sql
Solution
You really don't need the third collumn, unless you really want to store that value.
Anyway, to get the value :
SELECT TIMEDIFF(unload_time , record_time) AS dif FROM your_table LIMIT 1;
Problem
I have 2 columns called record time and unload time which are in time format "AM/PM" and I require a new column called total time to calculate difference between unload time and record time... For example here is my table: ``` record time unload time 11:37:05 PM 11:39:09 PM 11:44:56 PM 1:7:23 AM ``` I need a third column that contains the difference between these two columns. It must be in the following format: "1:1:1" For the above example, I need the output: ``` record time unload time total time 11:37:05 PM 11:39:09 PM 0:2:04 11:44:56 PM 1:7:23 AM 1:22:27 ``` How would I write a query to achieve this?