Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How to order by hours and minutes of a date column?
Thanks guys!
On Sun, 20 Jun 1999 20:10:31 GMT, tkyte_at_us.oracle.com (Thomas Kyte) wrote:
>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
Received on Mon Jun 21 1999 - 13:27:38 CDT
![]() |
![]() |