Filtering Trial Balance & General Ledger Reports based on dimensions showing mysql exception

I am getting the below error on trial balance & Genera ledger report,I’ve set finance book as accounts dimensions.

ERPNext Version 13.40

Syntax error in query:
account, sum(debit) as opening_debit, sum(credit) as opening_credit
from tabGL Entry
AND (finance_book in (%(finance_book)s, %(company_fb)s, ‘’) OR finance_book IS NULL) and finance_book in %(finance_book)s
and (posting_date < %(from_date)s or (coalesce(is_opening, ‘No’) = ‘Yes’ and posting_date <= %(to_date)s))
and account in (select name from tabAccount where report_type=%(report_type)s)
and is_cancelled = 0
group by account
Traceback (most recent call last):
File “apps/frappe/frappe/”, line 69, in application
response = frappe.api.handle()
File “apps/frappe/frappe/”, line 55, in handle
return frappe.handler.handle()
File “apps/frappe/frappe/”, line 38, in handle
data = execute_cmd(cmd)
File “apps/frappe/frappe/”, line 76, in execute_cmd
return, **frappe.form_dict)
File “apps/frappe/frappe/”, line 1457, in call
return fn(*args, **newargs)
File “apps/frappe/frappe/”, line 767, in wrapper_fn
retval = fn(*args, **get_newargs(fn, kwargs))
File “apps/frappe/frappe/desk/”, line 256, in run
result = generate_report_result(report, filters, user, custom_columns, is_tree, parent_field)
File “apps/frappe/frappe/”, line 767, in wrapper_fn
retval = fn(*args, **get_newargs(fn, kwargs))
File “apps/frappe/frappe/desk/”, line 90, in generate_report_result
res = get_report_result(report, filters) or []
File “apps/frappe/frappe/desk/”, line 71, in get_report_result
res = report.execute_script_report(filters)
File “apps/frappe/frappe/core/doctype/report/”, line 148, in execute_script_report
res = self.execute_module(filters)
File “apps/frappe/frappe/core/doctype/report/”, line 165, in execute_module
return frappe.get_attr(method_name)(frappe._dict(filters))
File “apps/erpnext/erpnext/accounts/report/trial_balance/”, line 32, in execute
data = get_data(filters)
File “apps/erpnext/erpnext/accounts/report/trial_balance/”, line 104, in get_data
opening_balances = get_opening_balances(filters)
File “apps/erpnext/erpnext/accounts/report/trial_balance/”, line 135, in get_opening_balances
balance_sheet_opening = get_rootwise_opening_balances(filters, “Balance Sheet”)
File “apps/erpnext/erpnext/accounts/report/trial_balance/”, line 196, in get_rootwise_opening_balances
gle = frappe.db.sql(
File “apps/frappe/frappe/database/”, line 174, in sql
self._cursor.execute(query, values)
File “env/lib/python3.8/site-packages/pymysql/”, line 148, in execute
result = self._query(query)
File “env/lib/python3.8/site-packages/pymysql/”, line 310, in _query
File “env/lib/python3.8/site-packages/pymysql/”, line 548, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File “env/lib/python3.8/site-packages/pymysql/”, line 775, in _read_query_result
File “env/lib/python3.8/site-packages/pymysql/”, line 1156, in read
first_packet = self.connection._read_packet()
File “env/lib/python3.8/site-packages/pymysql/”, line 725, in _read_packet
File “env/lib/python3.8/site-packages/pymysql/”, line 221, in raise_for_error
File “env/lib/python3.8/site-packages/pymysql/”, line 143, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.ProgrammingError: (1064, “You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘‘Head Office-HO’\n\t\t\tand (posting_date < ‘2021-04-01’ or (coalesce(is_openi…’ at line 6”)

Any help will be highly appreciated. Thank you.