将小时,分钟转换为天,小时,分钟

时间:2019-04-16 15:35:53

标签: sql sql-server

我有一个查询,以小时,分钟为单位显示停机时间,但需要以天,小时,分钟为单位显示,也许还有另一个显示天,小时为单位的查询

抱歉,我不擅长编码。

${SQL: SELECT CAST( CAST(('${N=Alerting;M=Downtime}') AS int) / 60 AS varchar) + ' hours '  + right('0' + CAST(CAST(('${N=Alerting;M=Downtime}') AS int) % 60 AS varchar(2)),2) + ' minutes'}

1 个答案:

答案 0 :(得分:0)

${SQL: SELECT CAST( CAST(('${N=Alerting;M=Downtime}') AS int) / 1440 AS varchar) + ' days '  + right('0' + CAST(CAST(('${N=Alerting;M=Downtime}') AS int) % 1440 / 60 AS varchar(2)),2) +  ' hours '  + right('0' + CAST(CAST(('${N=Alerting;M=Downtime}') AS int) % 60 AS varchar(2)),2) + ' minutes'}