Results 1 to 7 of 7

Thread: Time from Date

  1. #1
    Join Date
    Mar 2003
    Location
    Italy
    Posts
    17

    Unanswered: Time from Date

    Hello Everybody!
    Does it exist a way to find out the time (hour:minute:second) from a date type? I.e., I must compare the time between date columns, but the day/month/year are not parts in this comparison.
    Any idea?

    Thank you!

    Fausto

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    alter session set nls_date_format = 'YYYY-MON-DD:HH24:MIS';

  3. #3
    Join Date
    Apr 2003
    Location
    Greenville, SC (USA)
    Posts
    1,155
    select to_char(sysdate,'dd-mon-yy hh24:mi:ss') from dual;

    HTH
    Gregg

  4. #4
    Join Date
    Mar 2003
    Location
    Italy
    Posts
    17
    Well. I try to be clearer.
    I have a value, say '18/03/2004 14:30:00'.
    On my DB I have a table with 2 date columns, and the values on its rows are, say:
    '01/01/1970 08:00:00' - '01/01/1970 12:30:00'
    '01/01/1970 15:00:00' - '01/01/1970 18:00:00'
    and so on...

    I need to know if the time in my value, '14:30:00', is between the times in any row of my table. So, the first row goes from '8:00:00' and '12:30:00' and the second from '15:00:00' and '18:00:00'.
    But I don't know how can I compare only the time of the date fields.

    Thank you!

  5. #5
    Join Date
    Apr 2003
    Location
    Greenville, SC (USA)
    Posts
    1,155
    SELECT TO_CHAR(SYSDATE,'HH24:MIS') FROM DUAL;

    You can use between to get values ...

    HTH
    Gregg

  6. #6
    Join Date
    Mar 2003
    Location
    Italy
    Posts
    17

    Talking

    YES, your suggestion is arrived in the same time I've tried the same way! Well, now I'm sure this idea is correct.

    Thank you a lot, Greg!

  7. #7
    Join Date
    Apr 2003
    Location
    Greenville, SC (USA)
    Posts
    1,155
    Good Luck ...
    You might look at the different ways you can pull back the date (different formats ...)

    Gregg

Posting Permissions

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