如何用Mysql 对两个时间字段相减并取分钟值

2018年5月31日09:37:36 1 1,526 阅读

Mysql 对两个时间字段相减取分钟

1、字符串转时间

select str_to_date(`cleartime`,'%Y-%m-%d%H') as a FROM myolt

2、time_to_sec 取秒后转分钟

select `cleartime`,now(),time_to_sec(timediff(now(), str_to_date(cleartime,'%Y-%m-%d%H')))/60 as a from myolt WHERE `deviceip`='10.108.180.9'

如何用Mysql 对两个时间字段相减并取分钟值

hcyaobin

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

目前评论:1   其中:访客  0   博主  0   引用   1

    来自外部的引用: 1

    • 用webpagetest.org测试网页性能 – 文中之舞