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. 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 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 Link to comment https://forums.phpfreaks.com/topic/191668-date-range-problem/#findComment-1010313 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.