我有一个有4列的表。日期登录,日期注销,时间登录,时间注销。
我怎样才能得到改变。我试过这样的事情;
SUM(TIMESTAMP(date_logout, time_logout) - TIMESTAMP(date_log, time_log))
然而,我的数字非常高,我无法将其转换为适当的时间。任何提示或线索?我没有设计表btw:P
提前致谢!
答案 0 :(得分:1)
如果你想要几秒钟的差异:
SUM(UNIX_TIMESTAMP(TIMESTAMP(date_logout, time_logout)) - UNIX_TIMESTAMP(TIMESTAMP(date_log, time_log)))
如果你想要几天的差异:
SUM(DATEDIFF(TIMESTAMP(date_logout, time_logout), TIMESTAMP(date_log, time_log)))
如果你想将差异变为HH:mm:ss
SUM(TIMEDIFF(TIMESTAMP(date_logout, time_logout), TIMESTAMP(date_log, time_log)))
答案 1 :(得分:1)
使用TIMEDIFF FUNCTION减去这两个值。
TIMEDIFF(TIMESTAMP(date_logout, time_logout) ,TIMESTAMP(date_log, time_log) )
答案 2 :(得分:0)
TIMEDIFF(TIMESTAMP(date_logout, time_logout) , TIMESTAMP(date_log, time_log))