[Solved] How to convert the Varchar of sum to time using sql server 2008 [closed]


Try this:

DECLARE @SUM VARCHAR(50)='33.90';

SELECT CAST(CAST(LEFT(@SUM,CHARINDEX('.',@SUM,0)-1) AS INT)+
       CAST(SUBSTRING(@SUM,CHARINDEX('.',@SUM,0)+1,LEN(@SUM)) 
                                    AS INT)/60 AS VARCHAR(10))+'.'+
       CAST(CAST(SUBSTRING(@SUM,CHARINDEX('.',@SUM,0)+1,LEN(@SUM)) 
                                         AS INT)%60 AS VARCHAR(10))

result:

34.30

1

solved How to convert the Varchar of sum to time using sql server 2008 [closed]