我已经搜索了很多网站,但找不到解决办法。
我试着将两个时间戳差异相加,当它们以分钟为单位时:

SELECT COUNT(*) from `table`
WHERE
TIMESTAMPADD(MINUTE,
    TIMESTAMPDIFF(MINUTE,first_date,second_date),
    TIMESTAMPDIFF(MINUTE,fourth_date,third_date)
) > 15 AND status='Pending'

这是我目前所在的位置,但它返回一个空结果。
有人能给我一个答案吗?谢谢您。
我也试过但没用
SELECT COUNT(*) from `table`
WHERE
AddTime(TIMESTAMPDIFF(MINUTE,first_date,second_date),
        TIMESTAMPDIFF(MINUTE,fourth_date,third_date)
    ) > 15 AND status='Pending'

还有这个
SELECT COUNT(*) from `table`
    WHERE
    (TIMESTAMPDIFF(MINUTE,first_date,second_date)+TIMESTAMPDIFF(MINUTE,fourth_date,third_date))
        ) > 15 AND status='Pending'

最佳答案

在查询中,您正在逐分钟添加分钟,如果要使用TIMESTAMPADD函数,可以将分钟添加到日期
试试这个

SELECT *
from table
WHERE TIMESTAMPDIFF(MINUTE,first_date,second_date) + TIMESTAMPDIFF(MINUTE,fourth_date,third_date) > 120

关于mysql - 以分钟为单位的两个timestampdiff的总和,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30092631/

10-09 00:27