Search
 
SCRIPT & CODE EXAMPLE
 

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 */
Comment

convert minutes to hours in sql

SELECT minutes/60.0 AS hours FROM TABLE_NAME;

Comment

PREVIOUS NEXT
Code Example
Sql :: what is unique key in sql 
Sql :: mysql string split to array 
Sql :: first max salary in sql 
Sql :: SQL Syntax of INNER JOIN 
Sql :: changing column names in sql query results 
Sql :: operator in sql 
Sql :: vi set sql syntax 
Sql :: SQL isnumeric DB2 
Sql :: oracle last connection 
Sql :: sql foreign key constraint 
Sql :: fetlife 
Sql :: mysql bind-address default value 
Sql :: case vhdl 
Sql :: Search In the Database using Text 
Sql :: order by with where clause in mysql 
Sql :: uuid sqlalcomany 
Sql :: sql not in operator 
Sql :: last date for each user sql 
Sql :: microsoft sql server management studio uppercase shortcut 
Sql :: reindex mssql table 
Sql :: sql merge statement 
Sql :: mysql max connections exceeded max_connections_per_hour 
Sql :: postgresql show tables 
Sql :: sql server epoch to datetime 
Sql :: how to select only a certain date sql 
Sql :: equi joins in oracle 
Sql :: order by postgres 
Sql :: set up mssql in mac m1 
Sql :: synonym oracle 
Sql :: joining tables in sql 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =