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

Thread: How to select latest date

Hybrid View

  1. #1
    Join Date
    Jun 2000
    Location
    dumfries,va,usa
    Posts
    227

    How to select latest date

    Hi,

    How can I get to_date function to return the hours and minutes like to_char: HH24:MI. I'm only getting the date.

    Thanks,
    leo
    leonard905
    leonard905@yahoo.com

  2. #2
    Join Date
    Jan 2001
    Posts
    3,134
    SELECT TO_CHAR
    (SYSDATE, 'MM-DD-YYYY HH24:MI:SS')"NOW"
    FROM DUAL;

    http://download-west.oracle.com/docs...129a.htm#84850
    I remember when this place was cool.

  3. #3
    Join Date
    Jun 2000
    Location
    dumfries,va,usa
    Posts
    227
    It's not easy when you have a date like:

    31-OCT-2004 10:00 and 01-NOV-2004 13:00 and you want to get the latest date. ie. 01-NOV-2004 13:00.

    How do you do this. My query below brings back only the date and not the timestamp.


    select to_char(max(to_date(mod_date,'DD-MON-RR')), 'MON-DD-YYYY HH24:MI') from table1
    leonard905
    leonard905@yahoo.com

  4. #4
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    ah, the real question.

    of course, you're truncating the date.
    Jeff Hunter

  5. #5
    Join Date
    Jun 2000
    Location
    dumfries,va,usa
    Posts
    227
    Okay. So how should I do it. Any help is appreciated.
    leonard905
    leonard905@yahoo.com

  6. #6
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    1. Why do you have to convert to_date anyway?
    2. example structure, data, please
    Jeff Hunter

  7. #7
    Join Date
    Jun 2000
    Location
    dumfries,va,usa
    Posts
    227
    Thanks. I got it to work by adding a subquery:

    select to_char(mod_date, 'MON-DD-YYYY HH24:MI') NewDate from Table1
    where mod_date = (select max(mod_date) from Table1);
    leonard905
    leonard905@yahoo.com

  8. #8
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    Oh boy, what an SQL!

    select to_char(MAX(mod_date), 'MON-DD-YYYY HH24:MI') NewDate from Table1;
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

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