Я думаю, вы ищете что-то вроде этого
Declare @theMinutes Varchar(10)
Set @theMinutes = '19:25'
declare @totMintute int
Select
@totMintute = (Cast(
Cast(left(@theMinutes,charindex(':',@theMinutes)-1) as Int) * 60
+ Cast(substring(@theMinutes,charindex(',',@theMinutes)+4,len(@theMinutes)) as Int)
as Int ) * 60) / 60
--For 12 hour 1 days
Select @totMintute / 720 as NoDays -- 720 minutes per day
, (@totMintute % 720) / 60 as NoHours -- modulo 720
, (@totMintute % 60) as NoMinutes -- modulo 60
--For 24 hour 1 days
Select @totMintute / 1440 as NoDays -- 1440 minutes per day
, (@totMintute % 1440) / 60 as NoHours -- modulo 1440
, (@totMintute % 60) as NoMinutes -- modulo 60
Результат будет выглядеть так, как показано ниже.
Вы можете преобразовать эту таблицу источника данных запроса, как показано ниже.
Create table #Temp (MinValue Varchar(8))
insert into #Temp Values ('19:25')
Select TotMinute / 720 as NoDays -- 1440 minutes per day
, (TotMinute % 720) / 60 as NoHours -- modulo 1440
, (TotMinute % 60) as NoMinutes -- modulo 60
from(
select
(Cast(
Cast(left(MinValue,charindex(':',MinValue)-1) as Int) * 60
+ Cast(substring(MinValue,charindex(',',MinValue)+4,len(MinValue)) as Int)
as Int ) * 60) / 60 as TotMinute
from #Temp
)a
Вы можете найти живую демонстрацию здесь .