user1744093
user1744093

Reputation: 173

Mysql query delete a DATE that is older than 30 days from another date

Hello I am trying to create a query that deletes all data that is recorded as being before 2012/11/10 by 30 days. I am not sure how to do this as all I can think of is

DELETE FROM fines
WHERE 
fTime < (2012-11-10, INTERVAL 30 DAY)

However this gives me error 1292 incorrect date value

Can anyone point me in the right direction?

Upvotes: 2

Views: 3697

Answers (2)

dealer
dealer

Reputation: 474

Try this:

 delete from fines where ftime < DATE_SUB("2012-11-10" , INTERVAL 30 DAY)

http://sqlfiddle.com/#!2/d41d8/4100

Upvotes: 3

John Dvorak
John Dvorak

Reputation: 27287

try

DELETE FROM fines
WHERE 
fTime < ('2012-11-10' - INTERVAL 30 DAY)

http://sqlfiddle.com/#!2/d41d8/4099

Upvotes: 3

Related Questions