Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: How to order by hours and minutes of a date column?

Re: How to order by hours and minutes of a date column?

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Sun, 20 Jun 1999 20:10:31 GMT
Message-ID: <37744a18.8461156@newshost.us.oracle.com>


A copy of this was sent to y2000_at_pacbell.net (Y2K) (if that email address didn't require changing) On 20 Jun 1999 12:55:00 PDT, you wrote:

>I need to do a select and order the results by hours and minutes (from
>1-24 and 0-59) of a date column. I tried TRUNC function but it
>doesn't seem to work. This should be an easy question, but I can't
>find it from Oracle's documentation.
>
>Can someone help? Thanks!

If you need to order by hours and minutes (but not the date itself) try:

order by to_number( to_char( date_field, 'hh24mi' ) )

for example:

  1 select to_char( created, 'dd-mon-yyyy hh24:mi' ) from user_objects   2* order by to_number( to_char( created, 'hh24mi' ) ) SQL> / TO_CHAR(CREATED,'


14-jun-1999 06:40
14-jun-1999 06:40
14-jun-1999 06:59
14-jun-1999 07:00
14-jun-1999 07:00
14-jun-1999 07:00
18-jun-1999 08:08
18-jun-1999 08:08
18-jun-1999 08:47
16-jun-1999 09:13
16-jun-1999 09:14
16-jun-1999 09:17
16-jun-1999 09:19

--
See http://govt.us.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'... Current article is "Fine Grained Access Control", added June 8'th  

Thomas Kyte                   tkyte_at_us.oracle.com
Oracle Service Industries     Reston, VA   USA

Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Sun Jun 20 1999 - 15:10:31 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US