DBAsupport.com Forums - Powered by vBulletin
Results 1 to 9 of 9

Thread: date function

  1. #1
    Join Date
    Jan 2002
    Posts
    33
    i want to be able to substract date2 from date1 and display only hours and minutes, not mon, year, day or seconds; just hours and minutes.
    example
    date1 = 12/01/2001 21:00
    date2 = 01/01/2002 06:00
    when I do the substraction, I get say, 9:0
    I need to display 09:00
    can anyone help please?

  2. #2
    Join Date
    Jul 2000
    Posts
    521
    Can you give a valid example of what you need ?
    svk

  3. #3
    Join Date
    Jan 2002
    Posts
    33
    I have two dates in the format mm/dd/yyyy HH24:mi.
    I want to substract date2 from date1 and get the result in HH:MI
    for instance:
    date1 = 12/01/2001 21:00 --month/Day/YYYY Hours:Minutes
    date2 = 12/01/2001 06:00 --month/Day/YYYY Hours:Minutes
    When I substract date2 from date1, I want my result to be 09:00. Right now, the result is 9:0.

  4. #4
    Join Date
    Jul 2000
    Posts
    521
    Still, what I do not understand is how the result is 9:0 ?
    6am to 9pm on same date should be 15hrs. So, is that you want to see '15:00' as result ?
    svk

  5. #5
    Join Date
    Jan 2002
    Posts
    33
    Yes I want to see 15:00.
    the actual test data are:
    date1 = 01/22/2002 21:00
    date2 = 01/22/2002 06:00
    and the result is coming out as 9:0
    but the point I was trying to stress is I want 09:00
    as opposed to 9:00.
    Thanks again for all replies.

  6. #6
    Join Date
    Jul 2000
    Posts
    521
    Here it is :

    select to_char(trunc(sysdate)+(to_date('12/01/2001 21:00','MM/DD/YYYY HH24:MI')-to_date('12/01/2001 06:00','MM/DD/YYYY HH24:MI')),'HH24:MI') from dual;
    svk

  7. #7
    Join Date
    Jan 2002
    Posts
    33
    thanks svk, i really appreciate it!

  8. #8
    Join Date
    Dec 2001
    Location
    Brazil
    Posts
    282

    SELECT TO_CHAR(SYSDATE, 'HH24:MI') FROM DUAL;

    That's all.

    F.

  9. #9
    Join Date
    Jan 2002
    Posts
    33
    Mnemonical, did you read my question?

Posting Permissions

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


Click Here to Expand Forum to Full Width