On Thu, 2008-12-04 at 08:27 +0700, sangprabv wrote:

> Hi,
> I get stuck to build a query to select records between curdate() and the
> last 4 weeks and groupped by week. I tested with:
> 
> "SELECT * 
> FROM momtbak
> WHERE insertdate
> BETWEEN curdate( ) 
> AND curdate( ) - INTERVAL 4 week"
> 
> It doesn't work. Please help, TIA.


http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#operator_between

http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html#function_date-add

Untested, but something like this maybe?

"SELECT * FROM momtbak 
 WHERE insertdate 
 BETWEEN DATE_SUB(CURRENT_DATE(), INTERVAL 4 WEEK) AND CURRENT_DATE();"


Reply via email to