【问题标题】:Substraction between 2 Time columns in MySQLMySQL中2个时间列之间的减法
【发布时间】:2016-03-26 20:10:02
【问题描述】:

如何在 MySQL 中对 Time 类型的两列进行减法并在几分钟内得到结果?谢谢!

【问题讨论】:

    标签: mysql sql


    【解决方案1】:

    一种方法是先转换为秒,然后再转换为分钟:

    floor(time_to_sec(time1) - time_to_sec(time2) / 60) as MinutesDiff
    

    【讨论】:

    • 你忘了圆括号 demo floor((time_to_sec(time1) - time_to_sec(time2)) / 60) 或使用整数除法 (time_to_sec(time1) - time_to_sec(time2)) DIV 60 AS MinuteDiff
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-06-03
    • 2015-10-14
    • 2021-12-11
    • 1970-01-01
    • 2015-09-06
    • 1970-01-01
    • 2020-08-06
    相关资源
    最近更新 更多