fixed a SQL error for not required date and datetime fields where no value was selected