dannybrazil Posted August 18, 2009 Share Posted August 18, 2009 Hello Im looking for help with this chalenge: I have a database with "future events" in it. each even is given a DATE(example: Aug' 25 - film festival) and a user will see all of the future event ONLY WHAT i need here id a code the i can run every day (i can run it no problems) and it will DELETE old entries from the DB. lets say today is Aug' 12 so i want to delete ALL entries with a date OF Aug 11 and back Any help ? Danny Quote Link to comment https://forums.phpfreaks.com/topic/170829-delete-db-entry-after-a-given-date-phpmysql-help/ Share on other sites More sharing options...
Bjom Posted August 18, 2009 Share Posted August 18, 2009 DELECT FROM myTbl WHERE DATE(myDate) < CURDATE() assuming you have a field called myDate in the table myTbl that identifies the record's "age" and it needs to be a timestamp or date type. Quote Link to comment https://forums.phpfreaks.com/topic/170829-delete-db-entry-after-a-given-date-phpmysql-help/#findComment-900928 Share on other sites More sharing options...
dannybrazil Posted August 18, 2009 Author Share Posted August 18, 2009 Another question lets say i have 20 entries from today on i want to present JUST the 4 that are the closest to today ? today is 18/08/2009 i have entries from sep 1 on...( 1..2..3..4..6..8..15...23....29) but there ARE not order as i wrote here they are mixed is there any way to SQL by distance from current date ?(lets say 1 week in advanced) thanks Quote Link to comment https://forums.phpfreaks.com/topic/170829-delete-db-entry-after-a-given-date-phpmysql-help/#findComment-901263 Share on other sites More sharing options...
fenway Posted August 21, 2009 Share Posted August 21, 2009 Sure... use DATEDIFF(). Quote Link to comment https://forums.phpfreaks.com/topic/170829-delete-db-entry-after-a-given-date-phpmysql-help/#findComment-903211 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.