将时间从 '00:00:00.0000' 转换为 MM:SS mysql

converting time from '00:00:00.0000' to MM:SS mysql

在 Whosebug 上尝试了所有解决方案后,我仍然没有时间将其转换为 mm:ss。

我试过time_format,date_format,Substring,left,right。

我的查询是:

SELECT location,sec_to_time(AVG(time_to_sec(time_avg))) as timeAVG 
FROM test.test 
group by location

输出为:

'zone1', '00:26:13.3333'

或者对于其他项目是否有类似的方法是否有我尝试转换时间的所有上述方法但保留 0 代替我已删除的项目,例如

SELECT location,sec_to_time(AVG(time_to_sec(time_format(time_avg, '%i:%s')))) as timeAVG 
FROM test.test
group by location

会 return:

'zone1', '26:13:20.0000' 等同于 date_format

substringleftright 全部 return 与提供的第一个值相同

如果我运行:

select location,TIME_FORMAT(time_avg,'%i:%s') 
from test.test 
group by location

它将时间正确格式化为:

'zone1', '29:47'

但查询没有 return 我要的值。

这是你想要的吗?

select location,TIME_FORMAT(time_avg,'%i:%s.%f') from test.test group by location;