select *
from b
where
to_char(savetime,'yyyy-mm-dd hh24:mi')>to_char(sysdate,'yyyy-mm-dd hh24:mi')-30
请问,我用这语句查询当前时间前半小时的记录,为什么总是报'无效数字'错误,要怎样写才正确?
from b
where
to_char(savetime,'yyyy-mm-dd hh24:mi')>to_char(sysdate,'yyyy-mm-dd hh24:mi')-30
请问,我用这语句查询当前时间前半小时的记录,为什么总是报'无效数字'错误,要怎样写才正确?
to_char(sysdate-30,'yyyy-mm-dd hh24:mi')吧
在oracle中,时间类型的值直接相减就可以了,得到的是天数,你可以这样写select *
from b
where
round(sysdate-savetime)>30;--使用四舍五入函数将小数转化成整数
select sysdate,sysdate-1/(24*60)*30 from dual;
select *
from b
where
round((sysdate-savetime)*24*60) <= 30;
from b
where
to_date(savetime,'yyyy-mm-dd hh24miss')> (sysdate - TO_DSINTERVAL('0 00:30:00.00'))