2014-04-07 78 views
0

當用戶從下拉菜單中選擇一些項目時,我需要過濾gridview。所以我寫在編輯值的變化情況下,本查詢代碼,但我的查詢是錯誤如何在EditValue中爲GridView設置過濾器? Winforms Devexpress

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)InvoiceDate之前,2014年1月4日

2)InvoiceDate startfrom 2014年1月3日恩頓31-0302014

3)InvoiceDate thisweek即最後從現在

4)InvoiceDate過去一週7天即是正低(今天) - 14天7天

5)InvoiceDate thisMonth的是過去30天了

6)InvoiceDate LastMonth,現在是(今天) - 60日30天

幫我怎麼形成這個查詢

+0

爲什麼要使用DevExpress的過濾選項,而不是你可以用'DataView'過濾器? – Shell

回答

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' )

+0

謝謝tats工作正常 – Sri

相關問題