I have the following query that produces the desired result, except I would like to be able to control which 7 days constitute a grouping. Specifically I would like to run it Friday - Thursday or Monday - Sunday depending on the situation.
Here is the query I have so far:
and here is what some of the results look like:Code:SELECT COUNT( * ) AS reports_in_week, DATE( DATE_ADD( created, INTERVAL( 1 - DAYOFWEEK( created ) ) DAY ) ) AS Start_Date, DATE( DATE_ADD( created, INTERVAL( 7 - DAYOFWEEK( created ) ) DAY ) ) AS End_Date FROM posts GROUP BY WEEK( created ) LIMIT 0 , 30
So what I need to know is how to manipulate the query so I can control the start date to be Monday or Friday (or whatever depending on what is needed)Code:# Start_Date End_Date 3 2008-12-28 2009-01-03 22 2009-01-04 2009-01-10 13 2009-01-11 2009-01-17 10 2009-01-18 2009-01-24 11 2009-01-25 2009-01-31 3 2009-02-01 2009-02-07 1 2009-02-08 2009-02-14 2 2009-02-15 2009-02-21 12 2009-02-22 2009-02-28





Bookmarks