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.

Jean-Claude



> -----Original Message-----
> From: Christopher G Tantalo [mailto:[EMAIL PROTECTED]]
> Sent: July 25, 2002 11:14 AM
> To: Kipp James
> Cc: [EMAIL PROTECTED]
> Subject: Re: Help on querying between dates
>
>
> "Kipp, James" wrote:
>
> >
> > > You could also use the Oracle to_date function with a format string
> > > to format your dates.
> >
> > Thanks, adam
> > Something like this??:
> >
> > my $sth = $dbh->prepare("
> >                         SELECT *
> >                                 FROM stats
> >                                 WHERE sdate BETWEEN to_char($fromDate,
> > 'DD/MM/YYY')
> >                         AND to_char($toDate,'DD/MM/YYY')
> >                                 ";
> >     or die "Cannot prepare SQL statements from $DBI::errstr\n";
> >
> >
>
> i would think you would want to use the to_date function and not the
> to_char function if you are trying to do something between a certain date
> range in Oracle.  the syntax for what you are doing should be documented
> in the Oracle books.  I know I have done what you are trying to do, I just
> cant dig up the code right now.
>
> --
> -------------------------------
> Just Your Friendly Neighborhood
> _SPIDEY_
>
>

Reply via email to