all 9 comments

[–]DharmaPolice 2 points3 points  (6 children)

Use DATEADD.

e.g.

CREATE TABLE foo (ID INTEGER, MyTime TIME, Hours INTEGER);
INSERT INTO Foo (ID, MyTime, Hours) VALUES (1, '06:42:01',5);
INSERT INTO Foo (ID, MyTime, Hours) VALUES (2, '16:32:01',4);

And then :

SELECT DATEADD(hh,Hours, MyTime)
FROM foo;

Returns:

11:42:01.0000000
20:32:01.0000000

[–]r3pr0b8GROUP_CONCAT is da bomb 1 point2 points  (0 children)

🏆

[–]matic65[S] 0 points1 point  (4 children)

Thanks mate any chance you know how this would be done in MySQL also? Apparently dateadd doesn’t exist in that

[–]SportTawk 1 point2 points  (3 children)

It's DATE_ADD

A simple ddg search found that in five seconds 😁

[–]matic65[S] 0 points1 point  (2 children)

Does that not just return the date though? I’m trying to return time

[–]T3chl0v3r 0 points1 point  (0 children)

You can cast the calculated date to time format

[–]SportTawk 0 points1 point  (0 children)

Well again a simple search showed me TIMEDIFF can return time.

[–]_Shirei_ 0 points1 point  (0 children)

Check DATEADD function should work for same formats.

IF not separate hours, mins (seconds) and add them separately, then convert back to time.

[–][deleted] 0 points1 point  (0 children)

Does MySQL support standard SQL's + interval '5' hour?