我试图将自定义日期与sql中的日期字段进行比较。我完成了以下查询,但它返回了一个错误,这是正确的。我的日期值在date1
,并希望与sale.posting_date
合并。我尝试在此处阅读相关帖子,但没有用。可以有人帮我吗?
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
答案 0 :(得分:0)
这是一个简单的改变,现在我清除了它。
total_amount=frappe.db.sql("""SELECT SUM(sale.grand_total) FROM `tabSales Invoice` sale where sale.posting_date= %s """ % date1)