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')

Ronald

Reply via email to