2012-09-11 24 views
9

Dưới đây là truy vấn tôi đang chạy để nhận nội dung cập nhật trong một giờ qua.Oracle nhận hồ sơ được cập nhật trong một giờ qua

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 của chúng tôi là oracle và nó là không có

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. 

lý do cho sự thất bại này là gì?

Trả lời

26

chỉ Trừ 1/24 từ sysdate để có được thời điểm 1 giờ trước

select count(*) from my_table where last_updated_date >= (sysdate-1/24) 
Các vấn đề liên quan