我有十进制格式的时间,我需要有所作为
我试过如下
declare @hours decimal(10,5)
set @hours = 6.25 --6 Hrs and 25 mins
declare @hours1 decimal(10,5)
set @hours1 = 5.45 --5 Hrs and 45 mins
select CONVERT(varchar(10), CONVERT(int, cast(floor(@hours) as char(2)))-CONVERT(int, cast(floor(@hours1) as char(2))))+ '.'+ CONVERT(varchar(10),CONVERT(int, cast(floor(100*(@hours - floor(@hours))) as char(2)))-
CONVERT(int, cast(floor(100*(@hours1 - floor(@hours1))) as char(2))))
对于此示例,输出为 1.-20。我需要像 .40 这样的输出