Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2005
    Posts
    12

    Unanswered: Convert int to time

    Hi

    I'm new to db and I have a problem. I have integer, like 100, 118 and I have to convert this to time, like 118 -> 1:58. The reason is I have a column date (format date) and I have to add the integer to the date, so I need to change the format of my int to time (I think).

    thanks for help.

  2. #2
    Join Date
    Apr 2003
    Location
    Greenville, SC (USA)
    Posts
    1,155
    You'll need to write a little conversion routine ...

    ie, type this in sqlplus ...

    select to_char((trunc(sysdate)+(118/1440)),'dd-mon-yy hh24:mi:ss') from dual;

    Change the value of 118 to your INT values ...

    HTH
    Gregg

  3. #3
    Join Date
    Apr 2003
    Location
    NY
    Posts
    208
    Oracle allows for arithmatic operations on Dates.

    So if you want to add 1 day to a date

    date_column + int_column

    if your interger represents hours divide your int by 24

    date_column + (int_column / 24)

    if minutes

    date_column + (int_column / 24/60)

    if seconds

    date_column + (int_column / 24/60/60)

    in your case it appears your INT is minutes, so use

    date_column + (int_column /24/60)

    btw, in the previous example they use the TRUNC function. Only do this, if you want to reset the hours and minutes of your date_column

    HIH

  4. #4
    Join Date
    Feb 2005
    Posts
    12
    thanks for help

    works #1.
    Last edited by koolyce; 02-14-05 at 11:08.

Posting Permissions

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