﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / SQL Server Newbies  / Convert int to time / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Wed, 19 Jun 2013 10:14:56 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Convert int to time</title><link>http://www.sqlservercentral.com/Forums/Topic1383245-1292-1.aspx</link><description>You only calculated minutes.[code="sql"]SELECT CONVERT(VARCHAR,Duration / 3600) + ':' +CONVERT(VARCHAR,(Duration %3600) / 60) + ':' + RIGHT('00' + CONVERT(VARCHAR,Duration % 60),2) as DURATIONFROM (SELECT 16167 duration)CDR[/code]You should post in the right forum to avoid assumptions that will give you solutions that won't work for you.;-)</description><pubDate>Mon, 12 Nov 2012 11:18:53 GMT</pubDate><dc:creator>Luis Cazares</dc:creator></item><item><title>RE: Convert int to time</title><link>http://www.sqlservercentral.com/Forums/Topic1383245-1292-1.aspx</link><description>What did I post wrong? I read your best practices Etiquette.</description><pubDate>Mon, 12 Nov 2012 10:47:05 GMT</pubDate><dc:creator>bhelper</dc:creator></item><item><title>RE: Convert int to time</title><link>http://www.sqlservercentral.com/Forums/Topic1383245-1292-1.aspx</link><description>This is an SQL 2000 database my query is:SELECT EXTENSION, timestamp, CONVERT(VARCHAR,Duration / 60) + ':' + RIGHT('00' + CONVERT(VARCHAR,duration % 60),2) as DURATIONFROM  CDRWHERE (TIMESTAMP BETWEEN CONVERT(DATETIME, '2012-10-01 00:00:00', 102) AND CONVERT(DATETIME, '2012-10-31 23:59:59', 102))The DURATION field is int datatype and the raw data is 16167.  Conversion looks like 269:27 which should be 04:29:07 this is for one call.</description><pubDate>Mon, 12 Nov 2012 09:50:27 GMT</pubDate><dc:creator>bhelper</dc:creator></item><item><title>RE: Convert int to time</title><link>http://www.sqlservercentral.com/Forums/Topic1383245-1292-1.aspx</link><description>[quote][b]bhelper (11/9/2012)[/b][hr]I have a call accounting database for our telephone system the duration field is int and I need to convert to time then sum. The duration would be something like 6974 and I need to display 1:56:14 in the report. Also to sum total for the extension.[/quote]Calculate the sum first, then convert the answer to time.{Edit}  And, yes... I see that Luis already stated that.  Concurrence is always a good thing. :-D</description><pubDate>Fri, 09 Nov 2012 15:49:41 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Convert int to time</title><link>http://www.sqlservercentral.com/Forums/Topic1383245-1292-1.aspx</link><description>I'm not sure what are you trying to do. However, a simple way to convert seconds in int to time would be like this.[code="sql"]SELECT CAST( DATEADD( ss, 6974, 0) AS time)[/code]What happens when SUM is equal or greater than 86400 (seconds in one day)?You must use the SUM on the int value as it's not supported on time or datetime.</description><pubDate>Fri, 09 Nov 2012 14:45:02 GMT</pubDate><dc:creator>Luis Cazares</dc:creator></item><item><title>Convert int to time</title><link>http://www.sqlservercentral.com/Forums/Topic1383245-1292-1.aspx</link><description>I have a call accounting database for our telephone system the duration field is int and I need to convert to time then sum. The duration would be something like 6974 and I need to display 1:56:14 in the report. Also to sum total for the extension.</description><pubDate>Fri, 09 Nov 2012 14:32:16 GMT</pubDate><dc:creator>bhelper</dc:creator></item></channel></rss>