Ok, the error message is all Perl. Your sql command string isn't properly formed--and it probably won't work the way you expect. I would format your sql command in Perl, then send the whole thing to mysql. A combination of localtime and sprintf should work.
Try something like this:
@date = localtime(time) ;
# this formats the date for you, but leaves leading spaces
$date = sprintf("%4d%2d%2d",1900+$date[5],$date[4],$date[3]);
# this replaces the spaces with 0's
$date =~ s/\s/0/g ;
# now we can make a filename
$filename = $date.'SS.txt';
# create the sql select statement
$sql = "SELECT Caseid, Updtname, Updtaddr, Updtcsz, Payto, Chkname, Chkaddr, Chkcsz
INTO OUTFILE '$filename'
FIELDS TERMINATED BY ''
LINES TERMINATED BY '\r\n'
FROM miha2005.miha05
WHERE (Outcome=1 OR Outcome=2) AND Saqlang=3 AND Paid<>1 AND Payto<3 ";
# No we're all set to go
$sth = $dbh->prepare($sql);
$sth->execute ();
$sth->finish ();
$dbh->disconnect ();
There are lots of ways of getting this done. This is just one idea for you.