C
ccc31807
Running MySQL. I have a column in my table called 'eventdate' of type
date with values that look like '2009-03-10'. I want to query by year
and month only.
If I run this query: "SELECT * FROM EVENTS WHERE eventdate LIKE
'2009-03%';" I get all March, 2009 events.
However, I can't seem to find the correct syntax to do this:
sub get_events_by_month
{
my $d = shift; # a value like '2009-03'
$dbh = con(); # internal function that connects to DB
$sth = $dbh->prepare("SELECT * FROM EVENTS WHERE eventdate LIKE ?
%");
$sth->execute($t);
$hash = $sth->fetchall_hashref('id');
$sth->finish();
$dbh->disconnect();
return $hash;
}
I've tried a number of different statements, some using bind_param,
with no luck.
Suggestions? Thanks, CC.
date with values that look like '2009-03-10'. I want to query by year
and month only.
If I run this query: "SELECT * FROM EVENTS WHERE eventdate LIKE
'2009-03%';" I get all March, 2009 events.
However, I can't seem to find the correct syntax to do this:
sub get_events_by_month
{
my $d = shift; # a value like '2009-03'
$dbh = con(); # internal function that connects to DB
$sth = $dbh->prepare("SELECT * FROM EVENTS WHERE eventdate LIKE ?
%");
$sth->execute($t);
$hash = $sth->fetchall_hashref('id');
$sth->finish();
$dbh->disconnect();
return $hash;
}
I've tried a number of different statements, some using bind_param,
with no luck.
Suggestions? Thanks, CC.