Oracle在最近一小时内更新了记录

Poo*_*rna 11 sql oracle date-arithmetic

下面是我运行的查询,以获取最近一小时的更新.

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'));
Run Code Online (Sandbox Code Playgroud)

我们的数据库是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.
Run Code Online (Sandbox Code Playgroud)

这次失败的原因是什么?

Ted*_*haw 35

只需从sysdate中减去1/24即可获得1小时前的时间

select count(*) from my_table where last_updated_date >= (sysdate-1/24)
Run Code Online (Sandbox Code Playgroud)