Kiran V
Kiran V

Reputation: 69

Convert time to seconds in mysql

I am trying to convert time to seconds in mysql.

   IN_datetime           OUT_datetime         Duration
2013-09-14 17:58:50   2013-09-14 18:02:12 =     202

select time_to_sec(out_datetime - in_datetime )  from customer_1.reconcile 

My output comes as 3280 instead of 202.

Upvotes: 2

Views: 409

Answers (1)

Rider_BY
Rider_BY

Reputation: 1129

Try use this code:

SELECT TIMESTAMPDIFF(SECOND,'2013-09-14 17:58:50','2013-09-14 18:02:12') from test

Upvotes: 3

Related Questions