chipmunken Posted February 10, 2010 Share Posted February 10, 2010 Ok I want to make a quarry that get's data from current date and X days back in time. This is because I want to extract today's stats and compare them with previous days. This is what I got so far. SELECT * FROM `sla_gen` WHERE transaction_date BETWEEN CURDATE() AND DATE_SUB(CURDATE(), INTERVAL 5 DAY) I have fiddled around with ADDDATE() and some other functions but I'm totally lost. I don't even know if I'm on the right track here. A pointer in the right direction is much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/191668-date-range-problem/ Share on other sites More sharing options...
sader Posted February 10, 2010 Share Posted February 10, 2010 swicth CURDATE() with DATE_SUB(CURDATE(), INTERVAL 5 DAY) in places since u must use BETWEEN like this BETWEEN min_val AND max_val Quote Link to comment https://forums.phpfreaks.com/topic/191668-date-range-problem/#findComment-1010308 Share on other sites More sharing options...
chipmunken Posted February 10, 2010 Author Share Posted February 10, 2010 Thanks worked like a sharm Quote Link to comment https://forums.phpfreaks.com/topic/191668-date-range-problem/#findComment-1010313 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.