title: How to convert minutes into HH:MM:SS formate in sql server
body: <p>I am having a column in my sql server database table with datatype bigint.
  Now i need to convert this column into HH:MM:SS formate.
  For this i use this command</p>
  <h2></h2>
  <pre><code>SELECT cast(CONVERT(VARCHAR,DATEADD(MS,SUM(mFld),0),8) as Time) FROM tblm
  </code></pre>
  <p>But this command doesn't show right time duration.
  For right time duration i use this command</p>
  <h2></h2>
  <pre><code>SELECT rtrim(LTRIM(cast((mFld/(60*60)) as char)))+':' +rtrim(LTRIM(cast((mFld%(60*60))/(60)as char)))+':'+rtrim(LTRIM(cast(((mFld%(60*60))%(60)) as char))) FROM tblm
  </code></pre>
  <p>This command shows right result.But resulted data type is varchar.How can i convert this column in to time column with same result.</p>
  <h2>Example</h2>
  <pre><code>DECLARE @minites bigint;
  SET @minites = 5200020;
  SELECT rtrim(LTRIM(cast((@minites/(60*60)) as char)))+':' +rtrim(LTRIM(cast((@minites%(60*60))/(60)as char)))+':'+rtrim(LTRIM(cast(((@minites%(60*60))%(60)) as char)))
  SELECT cast(CONVERT(VARCHAR,DATEADD(MS,SUM(@minites),0),8) as Time)
  </code></pre>