简体   繁体   中英

MS SQL Query not working when i put where clause

I am writing a simple query to fetch Amount for a particular date. The query works well without where clause. But after putting where clause it does not fetches any record. Pls help.

My Query is

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

Also datatype of systemlastedittime is DT , I am not aware about its format whether it is in ddmmyyyy or mmddyyyy format.

Format should be yyyy-MM-dd

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

you might also try

set dateformat ymd

before your select statement. taken from MSDN https://msdn.microsoft.com/en-us/library/ms189491.aspx

Below is the query:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM