Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add seconds to a timestamp of a start date so that I can get an estimated end date?

Tags:

sql

timestamp

I have a Task object with a start_time and an estimated time in seconds. The start_time is stored in the database as a MYSQL DATETIME and the estimated time is stored as seconds. I would like to add the seconds to the start_time to get an estimated finish date.

like image 861
davidahines Avatar asked Mar 16 '11 13:03

davidahines


1 Answers

There is a lot in the link Neville gave, but cutting slightly to the chase...

my_date_time + INTERVAL xx SECOND


I think it is more correct to use DATE_ADD(), but as far as I know there is no performance difference.

like image 93
MatBailie Avatar answered Sep 17 '22 12:09

MatBailie