Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Help: Query Against an Indexed Date Field
A copy of this was sent to Peter Bishop <pjb_at_nortel.com>
(if that email address didn't require changing)
On Sun, 22 Nov 1998 13:22:30 +0000, you wrote:
>I have a large table with an indexed date field which I want to query
>against. The select statement is of the form:
>
>
>
> select .. from .. where (to_char(adate, 'DD-MON-YY') = '22-NOV-98';
>
>
>
>Question 1 is, will this select use the index? I don't think it will
>because I'm not using an actual value for the select.
>
>
it will not.
>
>Question 2 is, if the index is not used, is there a way to query on a
>date in a way which will use the index.
>
yes, try:
select .. from .. where adate between to_date( '22-NOV-1998', 'DD-MON-YYYY') and to_date( '22-NOV-1998 23:59:59', 'DD-MON-YYYY HH24:MI:SS' );
that will allow for an index range scan on the date field that will retrieve all records for november 22'cnd...
>
>
>Responses by email would be appreciated.
Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Herndon VA
--
http://govt.us.oracle.com/ -- downloadable utilities
Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Sun Nov 22 1998 - 09:16:28 CST
![]() |
![]() |