Hello Gentlemen,
I needed to execute this query:
SELECT distinct count (distinct holiday_date) from tabHoliday where holiday_date between '2022-01-01' AND '2022-01-03'
So I gave frappe.get_value() a try:
min_date = datetime.date(2022, 1, 1)
max_date = datetime.date(2022, 1, 3)
holidays = frappe.get_value("Holiday",
filters={'holiday_date': ['between', [min_date, max_date]]},
fieldname="count(distinct holiday_date)")
And was rewarded with this error:
pymysql.err.OperationalError: (4078, "Illegal parameter data types date and row for operation '='")
I solved this by using frappe.db.get_list() instead:
min_date = datetime.date(2022, 1, 1)
max_date = datetime.date(2022, 1, 3)
holidays = frappe.db.get_list("Holiday",
filters=[ ['holiday_date', 'between', [min_date, max_date]] ],
fields="count(distinct holiday_date)")
holidays = list(holidays[0].values())[0]
I would like the approach with frappe.get_value() better, but frappe.get_value() can’t either handle the between-condition or I’m getting the statement wrong.
Can anyone confirm this or contribute a working sample for using “between” with frappe.get_value()?