oracle日期相减的问题

2025-04-09 07:53:10
推荐回答(3个)
回答1:

设需要找昨天的数据,表名为 a ,日期字段为 rq
select * from a where trunc(sysdate-1)=trunc(rq)

trunc 可以拿到时间的日期部分

具体你根据你的情况完善一下。

回答2:

select ceil(to_date('2013-11-08 00:00:00','yyyy-mm-dd hh24:mi:ss')-to_date('2013-11-07 23:59:59','yyyy-mm-dd hh24:mi:ss')) from dual

用ceil,向上取整就好了嘛

回答3:

select sysdate-日期  from dual;
#得到的是你的那个日期和当前时间相差多少天