Q:

Comparing date in sql with custom date

I was trying to compare a custom date with date field in sql.I done the following query but it returned an error and rightfully so. I have my date value in date1 and want to comapare it with sale.posting_date.I tried reading the related posts here,but no use.Can anyone help me?
def get_total(filters):
 date1= filters.get("Date")
total_amount=frappe.db.sql("""SELECT SUM(sale.grand_total) FROM `tabSales    Invoice` sale,`tabPayment` payment where payment.parent=sale.name and   sale.posting_date = date1 """ )
return total_amount

A:

It was a simple change and now I cleared that.
total_amount=frappe.db.sql("""SELECT SUM(sale.grand_total) FROM `tabSales Invoice` sale where sale.posting_date= %s """ % date1)

