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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Help: Query Against an Indexed Date Field

Re: Help: Query Against an Indexed Date Field

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Sun, 22 Nov 1998 15:16:28 GMT
Message-ID: <365c2a5c.16198331@192.86.155.100>


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  



Opinions are mine and do not necessarily reflect those of Oracle Corporation  

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

Original text of this message

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