關於oracle的時間檢索問題

2021-07-03 21:22:01 字數 552 閱讀 4194

select d.name,d.id,(select count(1)

from cds002_message me

where d.id =me.doc_id

and me.createdate like to_date('2015-7-8','yyyy-mm-dd')) cnum,(select count(1)

from cds002_err_log m

where d.id =m.doc_id

and m.createdate like to_date('2015-7-8','yyyy-mm-dd')) ccnum

from c001_doc d

where d.type_code='2' and d.mode_code='1';

寫sql語句,會忽略掉資料庫裡面儲存的時分秒的統計出結果,如果把like換成=的話,就會匹配後面的時分秒就會查詢不出上面語句的結果。

再進行檢索就可以了。也可使用like進行檢索,但是效能方面來說,會消耗的大一點。所以不建議轉換成字串進行檢索。

在此記下來,幫助大家處理和解決次問題。

關於ORACLE時間儲存的問題

公司用oracle的資料庫,以前直接存實體的時候沒出現時間轉換問題。昨天,手寫sql語句 不是hql 時,傳date型別的資料給時間列,oracle報錯,不能識別,語句無效。解決方法共享 方法一 把date型別的資料,用 dateformat將date型別轉換成string 型別 dateforma...

關於oracle中時間查詢的問題

今天在新增新功能時遇到了乙個問題,在oracle中查詢5月31號執行的資料時,使用的語句為 1 if dateedit1.text.tostrtrim 2 sql and daystr to date dateedit1.datetime.tostring yyyy mm dd yyyy mm dd...

oracle關於時間的使用

一 加減 date型別可以直接加減天數,加減月份要勇add months select e.hiredate 30 24 60 60 20 24 60 5 24 as hiredate from emp e where rownum 1 1980 12 17 5 20 30 select e.hir...