Clicky

Please give me commands to delete rows older than 60 days from MySQL DB.

asked 01/31/2011 07:43

netsrini1's gravatar image

netsrini1 ♦♦


5 Answers:
DELETE * FROM  dbo.YourTable T WHERE T.YourDateColumn  < DATEADD(d,-60,GetDate())
link

answered

AkAlan's gravatar image

AkAlan

Try any of these queries.

DELETE FROM your_table
      WHERE datecolumn < ADDDATE(CURDATE(),INTERVAL -60 DAY);

DELETE FROM your_table
      WHERE datecolumn < DATE_ADD(CURDATE(),INTERVAL -60 DAY);
link

answered 2011-01-31 at 16:02:37

Sharath_123's gravatar image

Sharath_123

Replace "delete" with "select *" to see what you will be deleting just to make sure you get it right.  
link

answered 2011-01-31 at 18:19:01

aarontomosky's gravatar image

aarontomosky

Looks like I didn't read the post as careful as I should. My answer is not in MySql so disregard trying to make it work. Looks like Sarath 123 has the answer.
link

answered 2011-01-31 at 20:36:37

AkAlan's gravatar image

AkAlan

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

link

answered 2011-01-31 at 20:54:04

angelIII's gravatar image

angelIII

Your answer
[hide preview]

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×1

Asked: 01/31/2011 07:43

Seen: 210 times

Last updated: 12/17/2011 05:22