I think I'll need a phone call to understand what you are trying to do.
I'm starting to understand though... It might be:
$UpdateQuery->addFilter("substring(record_number,5,4)", "=", "s", "".((isset($_POST["UpdateYear"]))?$_POST["UpdateYear"]:"") ."");