简体   繁体   中英

between date and greater than date in Oracle SQL

Below is the data set and sysdate - 3rd Oct

ITEM    Date_from   Date_to
1234    1/1/2018    9/1/2018
1234    1/1/2018    10/1/2018
1234    1/1/2018    10/4/2018
1234    1/1/2019    12/31/2019

MY query:

select * from test_date where effect_to >= sysdate 
  minus
  select * from test_date where effect_to < sysdate ;

Correct Result:

1234    1/1/2018    10/4/2018
1234    1/1/2019    12/31/2019

Any better query ?

need to item dates which are currently effective and also effective for future dates.

I think you just want:

where effect_to > sysdate

or perhaps:

where effect_to >= trunc(sysdate)

depending on whether the last date is inclusive or exclusive.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM