2

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.

Kiran V
  • 69
  • 5
  • 16
  • 3
    Possible duplicate of [Calculate difference between two datetimes in MySQL](http://stackoverflow.com/questions/10907750/calculate-difference-between-two-datetimes-in-mysql) – Mike Zalansky Dec 17 '15 at 17:21

1 Answers1

3

Try use this code:

SELECT TIMESTAMPDIFF(SECOND,'2013-09-14 17:58:50','2013-09-14 18:02:12') from test
Bee
  • 12,251
  • 11
  • 46
  • 73
Rider_BY
  • 1,129
  • 1
  • 13
  • 31