sql query to find data between an interval.. something like getting data for each week

SELECT MAX( STR_TO_DATE( CONVERT( PurchaseDt

USING utf8 ) , '%m-%d-%Y' ) ) AS maxdate, MIN( STR_TO_DATE( CONVERT( PurchaseDt

USING utf8 ) , '%m-%d-%Y' ) ) AS mindate

FROM MemberEarnings

WHERE STR_TO_DATE( CONVERT( PurchaseDt

USING utf8 ) , '%m-%d-%Y' )

BETWEEN STR_TO_DATE( '08-01-2011', '%m-%d-%Y' )

AND STR_TO_DATE( '08-21-2011', '%m-%d-%Y' )

GROUP BY DATE_SUB( STR_TO_DATE( CONVERT( PurchaseDt

USING utf8 ) , '%m-%d-%Y' ) , INTERVAL DAYOFWEEK( STR_TO_DATE( CONVERT( PurchaseDt

USING utf8 ) , '%m-%d-%Y' ) ) -1

DAY )

Prashanth Madi

Prashanth Madi

I'm a programmer & Tech enthusiast. I work for OpenSource Support Team at Microsoft, but this blog, its content & opinions are my own. I blog about tech, gadgets, code, where we're going & we've been.

Read More