If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > Convert Minutes to Hours?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-04-09, 10:12
NickJ NickJ is offline
Registered User
 
Join Date: Sep 2003
Posts: 12
Convert Minutes to Hours?

Hi,

New to informix and still trying to get my head around the functions. Can anyone help me with writing a query to convert an integer of minutes to a format HH:MM?

In MSSQL I would use

select cast(@mins/60 as varchar(5)) + ':' + RIGHT('0' + cast(@mins%60 as varchar(2)), 2)

Put haven't a club how i'd do it in Informix. Can anyone help?

Thanks!
Reply With Quote
  #2 (permalink)  
Old 09-08-09, 16:32
ceinma ceinma is offline
Registered User
 
Join Date: Apr 2007
Location: Jundiai / SP - Brasil
Posts: 311
This can depend of the version of IDS are you using.
Considering the last version: 11.x

Code:
create temp table tp01 ( c1 int);
insert into tp01 values (610);
insert into tp01 values (10);
insert into tp01 values (270);

select cast (c1 units minute as interval hour to minute)  as a
      , to_date("00:00","%H:%M") + cast (c1 units minute as interval hour to minute) as b
      ,to_char ( to_date("00:00","%H:%M") + cast (c1 units minute as interval hour to minute) ,"%H:%M") as c
from tp01;
result, where the column C is a char:
Code:
a   10:10
b  2009-09-08 10:10:00.00000
c  10:10

a    0:10
b  2009-09-08 00:10:00.00000
c  00:10

a    4:30
b  2009-09-08 04:30:00.00000
c  04:30
__________________
________________________________________
César Inacio Martins
Jundiai / SP - Brasil
http://www.imartins.com.br/informix - em Português
http://www.imartins.com.br/informix - English (translated by Google).
________________________________________
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On