DECLARE
@start DATETIME = '2018-01-03 20:10:36.000',
@end DATETIME = '2018-01-03 22:10:37:000'
select IIF(convert(varchar(10), (DATEDIFF(SECOND, @start, @end ) / 86400)) = '0', '', convert(varchar(10), (DATEDIFF(SECOND, @start, @end )/86400)) + ' days ')
+ IIF(convert(varchar(10), ((DATEDIFF(SECOND, @start, @end ) % 86400) / 3600)) = '0', '', convert(varchar(10), ((DATEDIFF(SECOND, @start, @end )%86400)/3600)) + ' hours ')
+ IIF(convert(varchar(10), (((DATEDIFF(SECOND, @start, @end ) % 86400) % 3600) / 60)) = '0', '', convert(varchar(10), (((DATEDIFF(SECOND, @start, @end )%86400)%3600)/60)) + ' minutes ')
+ IIF(convert(varchar(10), (((DATEDIFF(SECOND, @start, @end ) % 86400) % 3600) % 60)) ='0', '', convert(varchar(10), (((DATEDIFF(SECOND, @start, @end )%86400)%3600)%60)) + ' seconds') as 'Duration'
My WordPress Blog
İlk Yorumu Siz Yapın