my @args = ($SearchPhrase); ... if ($begMonth) { ... $SQL .= " AND syslog_timestamp BETWEEN ? AND ?"; push @args, $begDate, $endDate; } ... $sth->execute(@args);