当用户从下拉列表中选择某个项目时,我需要过滤gridview。所以我在编辑值更改事件中编写此查询代码,但我的查询是错误
SELECT InvoiceId, InvoiceNumber, InvoiceDate,
(Select CustomerId from Customer Where Customer.CustomerId=NewInvoice_1.CustomerName) AS CustomerId,
(Select CustomerName from Customer where Customer.CustomerId = NewInvoice_1.CustomerName) AS CustomerName,
DueDate, Tax, GrandTotal, CompanyId
FROM NewInvoice_1
Where InvoiceDate < 06-04-2014; // error in where condition
此处我有6个条件来过滤此发票日期
1)2014年4月1日之前的InvoiceDate
2)InvoiceDate从01-03-2014 endon 31-0302014开始
3)InvoiceDate这是从现在起的最后7天
4)InvoiceDate上周现在(今天) - 14天到+7天
5)InvoiceDate从现在起30天内的ThisMonth
6)InvoiceDate LastMonth现在(今天) - 60天到+30天
帮助我如何形成对此
的查询答案 0 :(得分:0)
我认为你如何通过日期存在问题。
SELECT InvoiceId, InvoiceNumber, InvoiceDate,
(Select CustomerId from Customer Where Customer.CustomerId=NewInvoice_1.CustomerName) AS CustomerId,
(Select CustomerName from Customer where Customer.CustomerId = NewInvoice_1.CustomerName) AS CustomerName,
DueDate, Tax, GrandTotal, CompanyId
FROM NewInvoice_1
Where InvoiceDate < '06-04-2014';
这可能会起作用或将日期作为CDate('06 -04-2014')
传递