tags:

views:

328

answers:

5

Hi,

Can anyone help me with the script which will delete the data older than the particular date.

Thanks

+3  A: 
delete from YOUR_TABLE where your_date_column < '2009-01-01';
Pablo Santa Cruz
+2  A: 

This is pretty vague. Do you mean like in SQL:

DELETE FROM myTable
WHERE dateColumn < '2007'
Nick
+2  A: 

Delete data that is 30 days and older

   DELETE FROM Table
   WHERE DateColumn < GETDATE()- 30
TStamper
+1  A: 

or an ORACLE version:

delete
  from table_name
 where trunc(table_name.date) > to_date('01/01/2009','mm/dd/yyyy')
northpole
question has sqlserver tag
KM
my bad, I read a tag of "sql", sorry
northpole
+1  A: 

You could use:

DELETE FROM tableName
where your_date_column < '2009-01-01';

but Keep in mind that the above is really

DELETE FROM tableName
    where your_date_column < '2009-01-01 00:00:00';

Not

 DELETE FROM tableName
        where your_date_column < '2009-01-01 11:59';
Gern Blandston