randombits
randombits

Reputation: 48440

mysql: convert timediff() to seconds

I have a query that looks something like the following:

select timediff(time_end, time_begin) from tbl

time_end and time_begin are both of type datetime

Is there a trivial way I can convert the time there to return an integer (seconds)?

Upvotes: 8

Views: 18976

Answers (1)

Seva Kalashnikov
Seva Kalashnikov

Reputation: 4392

Mysql TIME_TO_SEC is what you are looking for

SELECT TIME_TO_SEC(timediff(time_end, time_begin)) from tbl

Upvotes: 18

Related Questions