开发者

Time bracket for SYSDATE

I need to se开发者_运维问答lect rows where timestamp is between now and 5 minutes in the past. How do I do it? Something like that:

select * from tableName where timestamp between sysdate and up to -5 min

The simpler - the better.


select *
  from tableName
 where timestamp between sysdate and sysdate - interval '5' minute

or old style:

select *
  from tableName
 where timestamp between sysdate and sysdate - 5 * 60 / 86400


SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') NOW
,           to_char(sysdate - 1/24/12,'yyyy-mm-dd hh24:mi:ss') "5 min. before"
    from dual;

NOW                 5 min. before
------------------- -------------------
2011-09-15 15:11:06 2011-09-15 15:06:06
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜