On Mon, 29 Jul 2002 09:46:04 -0400 Ronald J Kimball <[EMAIL PROTECTED]> wrote:

> On Thu, Jul 25, 2002 at 11:54:29AM -0400, Jean-Claude Girard wrote:
> > If you want entries on your $toDate to be included, you should use:
> > 
> >                         AND to_date($toDate,'DD/MM/YYY') +1
> > 
> > because to_date('01/01/02','DD/MM/YY') is the first of January 2002 at
> > precisely midnight and 0 seconds. The "+1" gives you until January 2nd, 2002
> > at midnight, thus including January 1st.
> 
> If you do it this way, then you have created a one-second overlap.  If you
> ran this query once for 2002-01-01 and once for 2002-01-02, then rows with
> a date and time of 2002-02-02 00:00:00 would be returned by *both*
> queries.
> 
> It is probably better to do the query like this:
> 
> BETWEEN TO_DATE('2002-01-01', 'YYYY-MM-DD')
>     AND TO_DATE('2002-01-01 23:59:59', 'YYYY-MM-DD HH24:MI:SS')

Or use '>=' and '<' instead of 'BETWEEN'.  Love those boundary conditions.

-- 
Mac :})
** I normally forward private questions to the appropriate mail list. **
Ask Smarter: http://www.tuxedo.org/~esr/faqs/smart-questions.html
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.


Reply via email to