这是自己写的方法,总觉得会有更好的办法实现这个效果呢?
SELECT case when CONVERT(nvarchar,DATEDIFF(SECOND,FinishAt,getdate() ))>86400 then CONVERT(nvarchar, DATEDIFF(SECOND,FinishAt,getdate() )/86400)+‘天‘+CONVERT(nvarchar, DATEDIFF(SECOND,FinishAt,getdate() )%86400/3600)+‘时‘+CONVERT(nvarchar, DATEDIFF(SECOND,FinishAt,getdate() )%86400%3600/60)+‘分‘+CONVERT(nvarchar, DATEDIFF(SECOND,FinishAt,getdate() )%86400%3600%60)+‘秒‘ when CONVERT(nvarchar,DATEDIFF(SECOND,FinishAt,getdate() ))>3600 then CONVERT(nvarchar, DATEDIFF(SECOND,FinishAt,getdate() )/3600)+‘时‘+CONVERT(nvarchar, DATEDIFF(SECOND,FinishAt,getdate() )%3600/60)+‘分‘+CONVERT(nvarchar, DATEDIFF(SECOND,FinishAt,getdate() )%3600%60)+‘秒‘ when CONVERT(nvarchar,DATEDIFF(SECOND,FinishAt,getdate() ))>60 then CONVERT(nvarchar, DATEDIFF(SECOND,FinishAt,getdate() )/60)+‘分‘+CONVERT(nvarchar, DATEDIFF(SECOND,FinishAt,getdate() )%60)+‘秒‘ else CONVERT(nvarchar,DATEDIFF(SECOND,FinishAt,getdate() ))+‘秒‘ end TimeSpend FROM [BPMDB].[dbo].[BPMInstTasks] A
原文地址:https://www.cnblogs.com/tianxiaotian/p/10277141.html
时间: 2024-10-04 09:30:51