如何在sql中将分钟转换为小时?

时间:2018-10-29 13:01:21

标签: sql sql-server tsql

我希望输出为:--11:25,但在几分钟内得到-685

select ClientName, JobName, JobTime, FileWriteTime,
    CAST(FileWriteTime as time(0))[Time],
        (DATEDIFF(MINUTE,CAST(FileWriteTime as time(0)),
        CONVERT(datetime,JobTime,120))) as Minutes
from StaleFileReport 
where ClientName ='AIA' and JobName ='MY-PTACOMB-TRD-LD' and convert(varchar,ReportTime,102) 
in ('2018.09.03','2018.09.10','2018.09.17','2018.09.24') order by convert(varchar,ReportTime,102)**

1 个答案:

答案 0 :(得分:0)

如下更改查询

select ClientName, JobName, JobTime, FileWriteTime,
   CONVERT(VARCHAR(5),FileWriteTime,108) HourMinute
from StaleFileReport 
where ClientName ='AIA' and JobName ='MY-PTACOMB-TRD-LD' and convert(varchar,ReportTime,102) 
in ('2018.09.03','2018.09.10','2018.09.17','2018.09.24') order by convert(varchar,ReportTime,102)