Patient List is reporting an error of Incorrect Date/Time

After adding a patient in openemr v5.0.1 version, if we try to click on the patient, the clinical reminders and recurrent appointments section are giving errors as follows:

Clinical reminders is giving errors as follows:

Query Error

ERROR: query failed: select tobacco from history_data where pid = ? and tobacco is not null and date >= ? and date <= ? order by date DESC limit 0,1

Error: Incorrect DATETIME value: ‘’

/var/www/html/openemr/library/patient.inc at 445:sqlQuery
/var/www/html/openemr/library/clinical_rules.php at 2122:getHistoryData(1,tobacco,2020-07-31 18:07:56)
/var/www/html/openemr/library/clinical_rules.php at 1704:exist_lifestyle_item(1,tobacco,current,2020-07-31 18:07:56)
/var/www/html/openemr/library/clinical_rules.php at 1168:database_check(1,Array,2020-07-31 18:07:56)
/var/www/html/openemr/library/clinical_rules.php at 798:test_filter(1,rule_tob_cess_inter,2020-07-31 18:07:56)
/var/www/html/openemr/library/clinical_rules.php at 69:test_rules_clinic(,passive_alert,2020-07-17 18:07:56,reminders-due,1,default,Array,primary,MHM-admin-89)
/var/www/html/openemr/interface/patient_file/summary/clinical_reminders_fragment.php at 28:clinical_summary_widget(1,reminders-due,2020-07-17 18:07:56,default,MHM-admin-89)

The Recurring Appointments section is giving the following error:

Query Error

ERROR: query failed: SELECT * FROM lists WHERE pid = ? AND type = ? AND (enddate is null or enddate = ‘’ or enddate = ‘0000-00-00’) ORDER BY begdate
Error: Incorrect DATE value: ‘’
/var/www/html/openemr/interface/patient_file/summary/stats.php at 64:sqlStatement

Kindly suggest solutions for these errors.

Thanks in advance

It looks like this might be happening because of possible change in the syntax of the mysql query.

After commenting out the check of an invalid date of NULL value, but retaining the other checks, the error went off in the execution of this query.