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: These WHERE clause are equal ?

Re: These WHERE clause are equal ?

From: Dieter Buecherl <Dieter.Buecherl_at_t-online.de>
Date: Wed, 27 Feb 2002 01:10:05 +0100
Message-ID: <a5h83l$i6t$00$1@news.t-online.com>


I don't think so, the result should be the same on either, but #2 might use an existing index (depending on the number of rows in the table), whereas #1 will not use an index

I usually write:

select * from TBL_LOG
WHERE stamp_date BETWEEN TO_DATE('04-02-2002', 'dd-mm-yyyy') AND TO_DATE('09-02-2002 23:59:59', 'dd-mm-yyyy hh24:mi:ss')

HTH Dieter

"R Chin" <rchin_at_ictgroup.com> schrieb im Newsbeitrag news:a5gq04$gg5$1_at_reader2.panix.com...
> Are the WHERE clauses below equivalent ?
>
> stamp_date has time stamp (ie '02/08/2002 12:57:51 PM')
> and I don't care about the time.
>
> Case 1)
> select * from TBL_LOG
> where TRUNC(stamp_date) BETWEEN '04-FEB-2002' AND '09-FEB-2002'
>
> Case 2)
> select * from TBL_LOG
> stamp_date BETWEEN TO_DATE('04-FEB-2002') AND TO_DATE('09-FEB-2002') +
> .99999
>
>
> rowid comparison seems to match.
>
> Thanks
>
>
>
>
Received on Tue Feb 26 2002 - 18:10:05 CST

Original text of this message

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