You already have your answer (although we don't yet know what it was), but you can reduce your logic by doing something like this:
my @args = ($SearchPhrase);
...
if ($begMonth) {
...
$SQL .= " AND syslog_timestamp BETWEEN ? AND ?";
push @args, $begDate, $endDate;
}
...
$sth->execute(@args);