I need a MySQL query for the following. I have a table of time duration as such below:
`hsncs_tbl`
+----+-----------------+
| Id | time_duration |
+----+-----------------+
| 1 | 0:12 |
---- -----------------
| 2 | 0:18 |
---- -----------------
Using a MySQL query, I need to be able to calculate these time duration. So from the table above I would get the answer of 0:30.
I tried this code many times, but still not working
SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(time_duration))) FROM hsncs_tbl
Here's the screenshot of my code together with the output.
Related questions:
How to get the sum of time from database?
You may use the following SQL Query:---
I hope that it will work according to your requirement.
Try this method:
in your Mysql query.
try this assuming time_duration is varchar column :
DEMO
Ops: i guessed you have Hours and minutes , if you have minutes and seconds just change the format.
try this one query in mysql
hope this will help you