First, this string works perfectly for automation in selenium:
dateofincident = self.dateEdit.date().toPyDate().strftime(\'%Y-%m-%d\')