Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2004
    Posts
    3

    Unanswered: how to use SELECT with INTERVAL

    I have a table like this:

    Name Null? Type
    ------------------ -------- ----------------------------
    SERVER_DATE NOT NULL DATE
    DURATION_TIME VARCHAR2(20)

    How can I use the column duration_time(such as 1:23:23) in my select statement?

    I try this :

    select to_char(server_date, 'MM/DD/YYYY HH24:MIS'), duration_time,to_char(server_date - (interval'duration_time' HOUR TO SECOND), 'MM-DD-YYYY HH24:MIS') from table1

    but doesn't work.

    Anyone, thanx in advance

  2. #2
    Join Date
    Jul 2003
    Posts
    2,296
    convert duration_time into seconds and then minus that from the date column

    so you would need to multiply "1" by 3600, "23" by 60 (1380), and add both of those to your seconds column "23" (5003 total seconds).

    the do: server_date - (5003/(86400)

    too bad you didn't load SECONDS into your duration column eh??

    There has got to be a better way to do all of that however.
    ANYONE?
    - The_Duck
    you can lead someone to something but they will never learn anything ...

  3. #3
    Join Date
    Nov 2002
    Location
    Desk, slightly south of keyboard
    Posts
    697
    Didn't you ask this earlier....?

    http://www.dbforums.com/t996140.html
    Please don't email me directly with questions. I've probably just got home from the pub and cannot guarantee the sanity of my answers. In fact, I can't believe I actually made it home.

Posting Permissions

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