Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

convert minutes to hours sql

DECLARE
    @FirstDate datetime,
    @LastDate datetime

SELECT
    @FirstDate = '2000-01-01 09:00:00',
    @LastDate = '2000-01-01 11:30:00'

SELECT CONVERT(varchar(12), 
       DATEADD(minute, DATEDIFF(minute, @FirstDate, @LastDate), 0), 114) 

/* Results: 02:30:00:000 */


/* For less precision  */
SELECT CONVERT(varchar(5), 
       DATEADD(minute, DATEDIFF(minute, @FirstDate, @LastDate), 0), 114) 
       
/* Results: 02:30 */
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #convert #minutes #hours #sql
ADD COMMENT
Topic
Name
5+9 =