Looks like a quoting problem.  

print $dbh->quote($mydate);

will print out the exact string that is binded to the query and you can
debug from there.

Ilya Sterin

-----Original Message-----
From: Jeff Boes
To: [EMAIL PROTECTED]
Sent: 6/6/01 8:43 AM
Subject: DBD::Pg and date operations


I have a date expression in a scalar like this:

$mydate = q!timestamp 'today' - interval '30 days'!;

I want to execute a statement like this:

$stmt = $dbh->prepare('SELECT * FROM foo WHERE date_added > ?');
$stmt->execute($mydate);

DBD::Pg reports that the date is invalid. But if I change this to

$stmt = $dbh->prepare("SELECT * FROM foo WHERE date_added > $mydate");

it's fine. What am I missing here?

-- 
Jeff Boes                                             vox 616.226.9550
Database Engineer                                     fax 616.349.9076
Nexcerpt, Inc.                                      [EMAIL PROTECTED]

Reply via email to