2015-02-11 64 views
0

我正在寫一個簡單的查詢來獲取特定日期的金額。查詢運行良好,沒有where子句。但是在放置where子句之後,它不會提取任何記錄。請幫助。MS SQL查詢不工作,當我把where子句

我的查詢是

Select 
OSTotal as RevenueDaily, 
systemlastedittime as Lastedittime 
from AccTransactionHeader where systemlastedittime = '09/02/2015' 

同樣的systemlastedittime數據類型爲DT,我不知道關於它的格式,不管是在ddmmyyyymmddyyyy格式。

回答

3

格式應該是yyyy-MM-dd

Select OSTotal as RevenueDaily, systemlastedittime as 
Lastedittime from AccTransactionHeader where 
CAST(systemlastedittime as DATE) ='2015-02-09' 
+0

感謝Ganesh神,它的工作。 – 2015-02-11 13:22:24

+0

@SurendraMourya歡迎您:) – 2015-02-11 13:22:41

0

下面採取 是查詢:

Select OSTotal as RevenueDaily, systemlastedittime as Lastedittime 
from AccTransactionHeader 
where CAST(systemlastedittime AS DATE)= '2/9/2015' 
+1

如果您正在編寫代碼,請在編輯器中將您的答案編寫爲代碼,以便將其突出顯示並易於理解。 – 2015-02-11 13:30:22