Delete tables only if days more than n days

General
Highlighted
Enthusiast

Delete tables only if days more than n days

I am looking for a solution that will delete bunch of tables if the date is greated than a column in the table 60 days

 

DELETE FROM TABLE_A WHERE CAST(LOAD_DS AS DATE) < NOW() - INTERVAL 60 DAY;

 

Here LOAD_DS  is a column name in table_A when the data was inserted in the table_A

 

Thank You,

 

 

 

 


Accepted Solutions
Ambassador

Re: Delete tables only if days more than n days

Teradata uses Standard SQL's CURRENT_DATE instead of NOW:

DELETE FROM TABLE_A 
WHERE CAST(LOAD_DT AS DATE) < CURRENT_DATE - 60;

 

1 ACCEPTED SOLUTION
1 REPLY 1
Ambassador

Re: Delete tables only if days more than n days

Teradata uses Standard SQL's CURRENT_DATE instead of NOW:

DELETE FROM TABLE_A 
WHERE CAST(LOAD_DT AS DATE) < CURRENT_DATE - 60;