我的样本表看起来像这样..
Primary_Key || Start_Time || End_Time || Value
1 || 24-FEB-13 18:00:00 || 24-FEB-13 19:00:00 || 6
这些列的数据类型是
Primary_Key -- Int
Start_Time --- TimeStamp
End_Time --- TimeStamp
Value --- Int
现在,我想获取表中当前时间为60分钟内End_Time值的所有记录?
答案 0 :(得分:1)
试试这个......
SELECT * FROM yourTable
WHERE end_time >= CURRENT_TIMESTAMP - NUMToDSInterval(1, 'HOUR')
这应该适用于DATE和TIMESTAMP以及TIMESTAMP WITH TIME ZONE值。
答案 1 :(得分:0)
这应该有效:
select *
from sample s
where CURRENT_TIMESTAMP - end_time <= 1/24.0 and CURRENT_TIMESTAMP >= end_time
答案 2 :(得分:0)
试试这个
select * from yourtable
WHERE (sysdate - End_Time) * 1440 between 0 and 60
答案 3 :(得分:0)
您可以尝试这一点 - 在your_start_date和your_start_date + INTERVAL&#39; 60&#39;之间选择您的数据。 MINUTE:
SELECT SYSDATE start_dt, (SYSDATE + INTERVAL '60' MINUTE) end_dt
FROM dual
/
SELECT * FROM
(
SELECT to_date('24-FEB-13 18:00:00', 'DD-MON-YYYY HH24:MI:SS') your_start_date
,(to_date('24-FEB-13 18:00:00', 'DD-MON-YYYY HH24:MI:SS') + INTERVAL '60' MINUTE) your_end_dt
FROM dual
)
/