如果我執行查詢Oracle查詢沒有返回預期的記錄
select * from my_table where status=5000
我從數據庫中獲取76條記錄。不過,我想按日期縮小範圍。幸運的是,該表中有一個receiveddate
列,其中一個記錄的receiveddate
爲「23-APR-13」。所以我試過這個查詢:
select *
from my_table
where status=5000
and receiveddate=to_date('23-APR-13', 'DD-Mon-YY')
並且返回0條記錄。
如果我使用
select *
from my_table
where status=5000
and receiveddate > to_date('20130423', 'YYYYMMDD')
and receiveddate > to_date('20130424', 'YYYYMMDD')
我得到正是我想要的。你們可以幫我理解差異/問題嗎?
'Date'數據類型的值總是包含時間部分。嘗試截斷它,'trunc(receiveddate)= to_date('23 -APR-13','DD-Mon-YY')' – 2014-09-23 19:31:44
我假設返回您期望的數據的查詢實際上是'receiveddate
2014-09-23 19:38:00