MSDN > 論壇首頁 > SQL Server Integration Services > convert minutes to hours
發問發問
 

問題convert minutes to hours

  • 2006年2月24日 下午 03:26esin gülten 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     

    hi,

    I want to convert minutes to hours. for example field_minutes=130minutes to 2:10 hours...

    select field_minutes from table---> how can I do?

     

所有回覆

  • 2006年2月24日 下午 03:42Jamie ThomsonMVP, 版主使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     

    Not sure what this has got to do with SSIS but its an interesting little puzzle for a Friday afternoon anyway.

    Paste the following into SSMS/QA and run it:

    declare @mins int

    set @mins = 130

    select cast(@mins/60 as varchar(5)) + ':' + RIGHT('0' + cast(@mins%60 as varchar(2)), 2)

     

    There are probably other, better, ways!!!

     

    -Jamie