2012-09-11 16 views
9

以下は過去1時間で更新を取得するために実行しているクエリです。オラクルは過去1時間でレコードを更新します

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時間前

select count(*) from my_table where last_updated_date >= (sysdate-1/24) 
の時間を取得するために、SYSDATEから1/24を引きます
関連する問題