Reputation: 334
I have 2 columns ( 1 TIME, 1 DATETIME ) with this formats:
TIME: 24:00:00
DATETIME: 2014-07-29 00:00:00
How can I sum this 24 hours into the datetime column and put the result in a third column?
Thank you!!!!
Upvotes: 1
Views: 1559
Reputation: 2584
Use TIMESTAMP() MySQL function
Try
SELECT TIMESTAMP('2014-07-29 00:00:00','24:00:00');
it gives
2014-07-30 00:00:00
I hope this works for you
Upvotes: 1
Reputation: 10336
You can do that with the ADDTIME function
SELECT ADDTIME(your_datetime, your_time) as your_sum
ADDTIME() adds expr2 to expr1 and returns the result. expr1 is a time or datetime expression, and expr2 is a time expression.
mysql> SELECT ADDTIME('2007-12-31 23:59:59.999999', '1 1:1:1.000002'); -> '2008-01-02 01:01:01.000001'
Upvotes: 3