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: SELECT on part of a date field

Re: SELECT on part of a date field

From: Cristian Veronesi <c.veronesi_at_crpa.it>
Date: Wed, 30 Jan 2002 12:55:23 +0100
Message-ID: <3C57DF2B.51241624@crpa.it>


Zorglub wrote:

> Hello, here is my select statement :
> SELECT * FROM ACTUALITE WHERE TO_CHAR(DateCrea,'MM')=1 AND TO_CHAR
> (DateCrea,'YYYY') = 2002 ORDER By Categorie, DateCrea DESC
>
> DATE_CREA is a field of the table ;-)
>
> Is it the best way to search for the part of a date (I mean, the fastest !)

If DATE_CREA is indexed and you wish to use the index, I think you have to use the following code instead:

SELECT * FROM ACTUALITE
WHERE DateCrea between to_date('01-01-2002','dd-mm-yyyy') and to_date('31-01-2002','dd-mm-yyyy')
ORDER By Categorie, DateCrea DESC

HTH
Regards, Cris

-- 
Cristian Veronesi ><((((º> http://www.crpa.it

"Do you pine for the nice days of minix-1.1, when men were men and wrote
their own device drivers?" (Linus Torvalds, comp.os.minix, 05-10-1991)
Received on Wed Jan 30 2002 - 05:55:23 CST

Original text of this message

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