2012-09-11 68 views
9

以下是我正在運行的最近一小時內獲取更新的查詢。Oracle在最近一小時內獲取記錄更新

select count(*) 
from my_table 
where last_updated_date between to_date(to_char(sysdate,'YYYY-MM-DD HH24'))-1/24 and to_date(to_char(sysdate,'YYYY-MM-DD HH24')); 

我們的DB是Oracle和它與

ORA-01861: literal does not match format string 
01861. 00000 - "literal does not match format string" 
*Cause: Literals in the input must be the same length as literals in 
      the format string (with the exception of leading whitespace). If the 
      "FX" modifier has been toggled on, the literal must match exactly, 
      with no extra whitespace. 
*Action: Correct the format string to match the literal. 

,這是什麼失敗的原因失敗?

回答

26

只是減去1/24從SYSDATE獲得的1小時前

select count(*) from my_table where last_updated_date >= (sysdate-1/24) 
時間