Home:ALL Converter>Oracle get records updated in last one hour

Oracle get records updated in last one hour

Ask Time:2012-09-11T15:42:20         Author:Sirish

Json Formatter

Below is the query I am running to get updates in last one hour.

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'));

Our DB is oracle and it is failing with

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.

What is the reason for this failure?

Author:Sirish,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/12364999/oracle-get-records-updated-in-last-one-hour
Ted Shaw :

just Subtract 1/24 from sysdate to get the time of 1 hour ago\n\nselect count(*) from my_table where last_updated_date >= (sysdate-1/24)\n",
2012-09-11T07:45:12
yy