0

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.

Peace /Adis

2
Contributors
1
Reply
12
Views
4 Years
Discussion Span
Last Post by pritaeas
0

the weeks/months stay the same even though the variable (start date) changes

Can you provide an example of what happens?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.