Link to home
Start Free TrialLog in
Avatar of Kenny Devorak
Kenny DevorakFlag for United States of America

asked on

Delete records mySQL

I have a date field and I would like to delete all records that are 180 days old.  How would I do this in mySQL?

my Date is stored as follows in the table: 2009-06-15

Table name is tblTrack
Field name is fHitDate

Thanks

Ken Devorak
Avatar of JChrison
JChrison
Flag of Greece image

DELETE FROM tblTrack WHERE fHitDate < getdate()-180
ASKER CERTIFIED SOLUTION
Avatar of cyberkiwi
cyberkiwi
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I guess there are many correct ways to do this, here's another:

delete from tblTrack where DATEDIFF(now(), fHitDate)>180
Another one is :

Delete from tblTrack where DateDiff(day, fHitDate, getdate()) >180