you could use the Oracle function of trunc() on your dates. Like this: my $sth = $dbh->prepare(" SELECT * FROM stats WHERE sdate BETWEEN trunc($fromDate) AND trunc($toDate)"); or die "Cannot prepare SQL statements from $DBI::errstr\n";
The trunc function used like that on a date returns jsut the date portion and not the time. Adam > -----Original Message----- > From: Kipp, James [SMTP:[EMAIL PROTECTED]] > Sent: Thursday, July 25, 2002 10:43 AM > To: [EMAIL PROTECTED] > Subject: Help on querying between dates > > I have a cgi query form where the user selects a date range to get data > from. > I used SYSDATE as a means of inserting the date/time stamp into the table. > But the user will be entering the dates like: 7/01/2002 to 7/25/2002. > SYSDATE puts the dates in like '7/23/2002 10:38:10 AM' my question is how > can i match on this date. Should i use perl to format the date or use the > Oracle/SQL query itself to match the date. What Oracle options could i use > to do this. > Thanks > > Here is the relevant code, so far: > -- > # get the date strings from the form > my $fromDate = $q->param('fromDate'); > my $toDate = $q->param('todate'); > ...... > > # plug into query > my $sth = $dbh->prepare(" > SELECT * > FROM stats > WHERE sdate BETWEEN $fromDate AND $toDate"); > or die "Cannot prepare SQL statements from $DBI::errstr\n"; >