waynew Posted November 20, 2008 Share Posted November 20, 2008 I've been asked to get rid of old orders after a certain time period. Column in question uses datetime. i.e 2008-11-20 09:00:00 How could I delete everything that comes before that certain date. Would it be: WHERE orderDate < '2008-11-20 09:00:00' Or WHERE orderDate > '2008-11-20 09:00:00' Quote Link to comment https://forums.phpfreaks.com/topic/133539-solved-quick-question-regarding-deletion-of-certain-dates/ Share on other sites More sharing options...
premiso Posted November 20, 2008 Share Posted November 20, 2008 WHERE orderDate < '2008-11-20 09:00:00' Less than the specific date for older greater than specific date for newer. I would also setup a test DB to test this out if you are afraid of wiping the wrong data, that way you know it works. Quote Link to comment https://forums.phpfreaks.com/topic/133539-solved-quick-question-regarding-deletion-of-certain-dates/#findComment-694589 Share on other sites More sharing options...
.josh Posted November 20, 2008 Share Posted November 20, 2008 2nd one. We move forward in time, so anything you want removed before now (or whenever) would be less than now (or whenever) Quote Link to comment https://forums.phpfreaks.com/topic/133539-solved-quick-question-regarding-deletion-of-certain-dates/#findComment-694590 Share on other sites More sharing options...
gevans Posted November 20, 2008 Share Posted November 20, 2008 You could run a test first, use SELECT instead of DELETE through phpMyAdmin, then you'll see all the rows that you will be deleting (but the guys are right, you want less than) Quote Link to comment https://forums.phpfreaks.com/topic/133539-solved-quick-question-regarding-deletion-of-certain-dates/#findComment-694592 Share on other sites More sharing options...
waynew Posted November 20, 2008 Author Share Posted November 20, 2008 Thought so. Just figured I'd get a second opinion before I went waltzing in there deleting orders! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/133539-solved-quick-question-regarding-deletion-of-certain-dates/#findComment-694593 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.