Raj
Raj

Reputation: 1

Trying to fetch records older than 30 days in oracle sql

I am trying to fetch the records in Oracle sql which is older than 30 days (from Mod_date) and I am using the below query and it is returning all the data and I want only 30 days old data. Will you please anyone help me to correct this query Sample :- Mod_date 03-NOV-12 12.00.00.000000000 AM Query :-

select Mod_date 
from fil_cnfact 
where Mod_date <= sysdate -30 
order by Mod_date asc ;

Upvotes: 0

Views: 11941

Answers (1)

Matt Busche
Matt Busche

Reputation: 14333

Your query is asking for all records less than or equal to 30 days from today. Change your operator to = only to request records that are 30 days old.

select Mod_date 
from fil_cnfact 
where trunc(Mod_date) = trunc(sysdate)-30 
order by Mod_date asc ;

Upvotes: 1

Related Questions