The code below is to select and then echo stuff from my db grouped by either weeks or months. I have a couple of more of these and then use offset to get the second week etc.
FROM my_db WHERE DATE >= CURDATE() - INTERVAL 10 ".$grouping1." GROUP BY ".$grouping."(DATE) order by DATE desc limit 1
I have two questions:
I would like to exchange curdate() with a variable instead so that we are able to "pick a startdate" and then look 10 weeks/months back from that date.
Is there a simpler/better way to do this?
I've tried to exchange the curdate with a variable like this:
FROM my_db WHERE DATE >= '". $startdate ."' - INTERVAL 10 ".$grouping1." GROUP BY ".$grouping."(DATE) order by DATE desc limit 1
but the weeks/months stay the same even though the variable (start date) changes.
My $startdate variable is formatted like this 2013-05-07 and the DATE column in the mysql db is of date format.