Delete rows that are 2 weeks or older

Database
Enthusiast

Delete rows that are 2 weeks or older

hi 

 

I'm trying to delete rows that are 2 weeks or older

 

This is my SQL can someone help and amend i'm getting 0 returns when executed 

DELETE FROM PII_EXCLUSION_REFERENCE_ST
WHERE LOAD_DTE < ADD_MONTHS(DATE, -24);


Accepted Solutions
Teradata Employee

Re: Delete rows that are 2 weeks or older

Hi Blazio,

 

Well, 24 months is two years, not two weeks.

Try one of those :

delete from PII_EXCLUSION_REFERENCE_ST
 where LOAD_DTE < current_date - 15;

delete from PII_EXCLUSION_REFERENCE_ST
 where LOAD_DTE < current_date - interval '15' day;
1 ACCEPTED SOLUTION
3 REPLIES 3
Teradata Employee

Re: Delete rows that are 2 weeks or older

Hi Blazio,

 

Well, 24 months is two years, not two weeks.

Try one of those :

delete from PII_EXCLUSION_REFERENCE_ST
 where LOAD_DTE < current_date - 15;

delete from PII_EXCLUSION_REFERENCE_ST
 where LOAD_DTE < current_date - interval '15' day;
Enthusiast

Re: Delete rows that are 2 weeks or older

Hi Walder,

 

Thank you that worked perfectly for me i was confused. Quick question why did you say 15 and not 14 just curious thanks again 

Teradata Employee

Re: Delete rows that are 2 weeks or older

Because it's a strict lesser operator.

Providing LOAD_DTE is a date, which I assumed true according to the column name, both following queries are the same :

delete from PII_EXCLUSION_REFERENCE_ST
 where LOAD_DTE < current_date - 15;

delete from PII_EXCLUSION_REFERENCE_ST
 where LOAD_DTE <= current_date - 14;