0

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
LaksHmiSekhar
  • 315
  • 2
  • 7
  • 16
  • Probably these two links could help you http://stackoverflow.com/questions/775296/python-mysql-with-variables http://stackoverflow.com/questions/902408/how-to-use-variables-in-sql-statement-in-python – Maximilian Ast Feb 25 '15 at 12:56
  • @MaximilianAst I am using frappe framework . That is why this seems so different. – LaksHmiSekhar Feb 25 '15 at 13:06

1 Answers1

0

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)
LaksHmiSekhar
  • 315
  • 2
  • 7
  • 16