Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2003
    Posts
    12

    Unanswered: 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!

  2. #2
    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).
    ________________________________________

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •