MySql difference between two timestamps in Seconds?

后端 未结 3 1801
夕颜
夕颜 2021-01-30 13:22

Is it possible to calculate difference between two timestamps in Mysql and get output result in seconds? like 2010-11-29 13:16:55 - 2010-11-29 13:13:55 should give 180 seconds.<

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-30 13:33

    TIMESTAMPDIFF method only works with datetime format. If you want the difference between just two times like '11:10:00' minus '10:20:00' then use

    select TIME_TO_SEC('11:10:00')-TIME_TO_SEC('10:20:00')
    

提交回复
热议问题