sql server 2008 r2 - sql query date formatting (Hours:Minutes) -


how display values hours:minutes format (eg 77, result: 1:17)

info :

select      sum([travel time] + [total productive time])        vaction_reg       incident_id = '10064068' 

result: 77.00

need result in below format

(1:17) 

changed query:

select( select isnull(sum(action.service_time), 0) expr1     dbo.act_reg action      inner join dbo.act_type on action.act_type_id = dbo.act_type.act_type_id     (dbo.act_type.act_type_n in ('travel time')) , (action.incident_id = inc.incident_id)) [travel time],    ( select  isnull(sum(action.service_time), 0) expr1       dbo.act_reg action       inner join dbo.act_type act_type_6 on action.act_type_id = act_type_6.act_type_id      (act_type_6.act_type_n not in ('travel time', 'site departure')) , (action.incident_id = inc.incident_id)) [total productive time],      ( select cast(total / 60 varchar(8)) + ':' + cast(total % 60 varchar(2))                 ( select cast(sum([travel time] + [total productive time]) int) total) t) [total service time]                                  dbo.incident inc           inner join dbo.assyst_usr on inc.ass_usr_id = dbo.assyst_usr.assyst_usr_id           inner join dbo.serv_dept on dbo.assyst_usr.serv_dept_id = dbo.serv_dept.serv_dept_id            (inc.incident_ref ='64483') 

you can divide hours, mod remaining minutes:

select  cast(fld / 60 varchar(8)) + ':' + cast(fld % 60 varchar(2)) 

update ?money? - assumes no fractional parts;

select      cast(total / 60 varchar(8)) + ':' + cast(total % 60 varchar(2))  (     select          cast(sum([travel time] + [total productive time]) int) total              vaction_reg               incident_id = '10064068' ) t 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -

jdbc - Not able to establish database connection in eclipse -