oracle中的日期差异

时间:2013-10-24 01:33:18

标签: sql oracle

这个问题可能是愚蠢的,也可能是重复的,但我没有得到确切的答案

我有一个具有日期格式列(eff_date)的表,我想要sysdate和一个eff_date之间的差异超过两年且等于两年的数据

我正在使用此查询,我知道它的语法错误

select * 
from Customer 
where (select floor(months_between(sysdate,eff_date)/12) 
       from Customer t) >= 2

1 个答案:

答案 0 :(得分:1)

如果您想使用months_between

SELECT *
  FROM customer
 WHERE months_between( sysdate, eff_date ) >= 24

如果eff_date上有索引,您可能需要

SELECT *
  FROM customer
 WHERE eff_date <= sysdate - interval '2' year
相关问题