我有五个输出(这是查询TIMEDIFF(out_time, in_time)
) - > 9:04:04, 8:56:16, 9:43:09, 9:40:03
当我使用此SUM(TIMEDIFF(out_time, in_time)) as 'Working hours'
查询获取此次总和时,我会得到 364332 ,但我想要的是时间格式 37:23:32 是有没有代码要做?
答案 0 :(得分:1)
您可以使用MySQL函数SEC_TO_TIME()
SELECT SEC_TO_TIME(SUM(TIMEDIFF(out_time, in_time))) as Working hours
答案 1 :(得分:0)
试试这个:
select DATE_FORMAT(FROM_UNIXTIME(SUM(TIMEDIFF(out_time, in_time))) ,'%H:%i:%s') as 'Working hours'
答案 2 :(得分:0)
试试这个:
Select SEC_TO_TIME(SUM(TIME_TO_SEC(timediff(out_time, in_time)))) AS workingHours
答案 3 :(得分:0)
这是我做了它的工作
CONCAT(
FLOOR(
SUM(CASE WHEN TIME_TO_SEC(TIMEDIFF(out_time,in_time))<=0 THEN TIME_TO_SEC(TIMEDIFF(out_time,in_time))=''
ELSE TIME_TO_SEC(TIMEDIFF(out_time,in_time)) END)/3600) ,':',
FLOOR(MOD(
SUM(CASE WHEN TIME_TO_SEC(TIMEDIFF(out_time,in_time))<=0 THEN TIME_TO_SEC(TIMEDIFF(out_time,in_time))=''
ELSE TIME_TO_SEC(TIMEDIFF(out_time,in_time)) END),3600)/60)) as 'WORKING HOURS'