How to use 'between' operator in frappe.db.count



How do i use the between operator in frappe.db.count.?

I tried the below
count= frappe.db.count('Sales Invoice', {'date': ['between', [from_date, to_date]]})
but gets the value as 0 even though there are records.

The below works to fetch the records though,
invoice= frappe.get_all('Sales Invoice', filters={'date': ['between', [from_date, to_date]]}
This will fetch the records between the start date and end date.

However i need to get the count of the records. Appreciate a little help here. Thank you.

Can’t you use count = len(invoice) or count = invoice.count() ?
I didn’t check if get_all return an array or tuples.

count= len(invoice) did the trick. Thank you @FHenry.

Out of curiosity, what is the correct syntax for frappe.db.count or any frappe db api to use ‘betweeen’ operator as filter?

I’m not sure but into frappe-bench/apps/frappe/frappe/database/ the count method don’t manage the filters as get_all method do. “between” sql trick seems not possible.
May be old school way, something like
{[‘date’ ,‘>=’, ’ from_date’],[‘date’ ,‘<=’, ‘to_date’]}

ok. i guess only basic filters work for count method.