Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: SELECT on part of a date field
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