在MySql中将小时格式转换为hh:mm:format

在MySql中将小时格式转换为hh:mm:format,mysql,Mysql,目前我正在SQL中执行此操作: select emp_code,in_time,out_time,worked_time,WT,shift_work_time, case when enable_overtime = 1 and TIMEDIFF(WT,shift_work_time) > 0 then hour(TIMEDIFF(WT,(shift_work_time))) else 0 end as OT FROM myTable; 我在第8行的OT出错了,因为轮班工

目前我正在SQL中执行此操作:

    select emp_code,in_time,out_time,worked_time,WT,shift_work_time,
    case when enable_overtime = 1 and TIMEDIFF(WT,shift_work_time) > 0
then hour(TIMEDIFF(WT,(shift_work_time))) else 0 end as OT
FROM myTable;
我在第8行的OT出错了,因为轮班工作时间是以小时为单位的,所以我想将轮班工作时间(以小时为单位)转换为hh:mm:ss,我该怎么做? 先谢谢你

我也试过了
TIME\u格式(轮班工作时间,%H:%i:%s')
但当轮班工作时间为
10
时,输出为
00:00:10
,但应为

10:00:00

使用
STR\u TO\u DATE
(轮班工作时间,“%H”)


谢谢你的帮助,我想格式化处于if条件下的shift_worke_时间,我在输出中得到00:00,然后您必须使用casewhen@user9862376在检查时使用case编辑我的答案请仅在我的轮班工作时间为10时有效,但在我的轮班工作时间为10:00时不提供输出:00@user9862376您可以使用时间格式(“19:30:10”,“%H%i%s”);此格式化检查在此处;
 SELECT 
  select emp_code,in_time,out_time,worked_time,WT,(shift_worke_time,'%H') as shift_worke_time,
    case when enable_overtime = 1 and TIMEDIFF(WT,(shift_worke_time,'%H')) > 0
then hour(TIMEDIFF(WT,(shift_worke_time,'%H'))) else 0 end as OT
FROM myTable;