Troy,
If you are using a date field, then you don't have to convert the dates and
you can use the ODBC Date escape format to ensure *mostly* consistent usage,
certainly within MS Access and SQL Server. Other ODBC drivers don't
*always* play nicely.
The format is:
{d 'YYYY-MM-DD'}
or
{ts 'YYYY-MM-DD HH:MI:SS'}
Also, if you are going do do this repeatedly, then you should probably:
$dbh->prepare("SELECT * FROM myTable WHERE dt_field BETWEEN ? and ?)
$dbh->execute("{d '1998-05-05'}", "{d '1999-07-06'}");
or
$dbh->prepare("SELECT * FROM myTable WHERE dt_field BETWEEN ? and ?)
$dbh->bind_param(1, "{d '1998-05-05'}", { TYPE => SQL_DATE });
$dbh->bind_param(2, "{d '1999-07-06'}", { TYPE => SQL_DATE });
$dbh->execute;
Jeff
> -----Original Message-----
> From: Troy Sniff [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, May 08, 2002 10:12 PM
> To: [EMAIL PROTECTED]
> Subject: RE: Performing select by date
>
>
> Hmmm ...
>
> I wonder if this will work with Access. It would require me to go in
> and convert the dates to that format, but if it works, I would be
> willing to do it. I sure don't want to convert dates unless I know for
> sure.
>
> It would also need to work in Microsoft SQL Server since this database
> will eventually be converted over.
>
> Anyone have any idea on this?
>
> Troy
>
>
> > -----Original Message-----
> > From: Stephen Keller [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, May 08, 2002 4:30 PM
> > To: 'Troy Sniff'; [EMAIL PROTECTED]
> > Subject: RE: Performing select by date
> >
> > Troy, you asked about filtering results to get values between two
> > datetimes:
> >
> > > Is there a way to use the select statement to grab the
> > > entries that fall between the two dates?
> >
> > How about using a BETWEEN predicate in the where clause to limit the
> query
> > results? For example:
> >
> > SELECT
> > *
> > FROM
> > myTable
> > WHERE
> > dt_field BETWEEN '2002-04-18 00:00:00' and '2002-04-18 23:59:59'
> >
> > This is what I do (in IBM DB2 7.3) to select only a range of
> datetimes.
> >
> > Stph
>
>