Home » SQL & PL/SQL » SQL & PL/SQL » delete records older than 60 days....
delete records older than 60 days.... [message #2987] Wed, 28 August 2002 07:29 Go to next message
hogan
Messages: 2
Registered: August 2002
Junior Member
newbie wants to delete records with a transaction time older than 60 days (in a daily job). any comparison available in sql to do this easily?
Re: delete records older than 60 days.... [message #2990 is a reply to message #2987] Wed, 28 August 2002 09:30 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
delete
  from t
 where tran_date < (sysdate - 60);


Add a TRUNC on the right side if you want to exclude the partial day factor (the elapsed portion of the current day).

If you ever want an exact 2-month interval:

delete
  from t
 where tran_date < add_months(sysdate, -2);
Re: delete records older than 60 days.... [message #3004 is a reply to message #2987] Wed, 28 August 2002 16:59 Go to previous message
hogan
Messages: 2
Registered: August 2002
Junior Member
thanks todd!
Previous Topic: super sql genius' group by question
Next Topic: define_editor -- and keep it that way!
Goto Forum:
  


Current Time: Wed Apr 17 22:24:07 CDT 2024