From: Peter Brawley Date: December 29 2009 6:49pm Subject: Re: Weeks List-Archive: http://lists.mysql.com/mysql/219981 Message-Id: <4B3A4F31.3080804@earthlink.net> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="------------060901080104030007080607" --------------060901080104030007080607 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit ML, >trying to write some SQL that will give me records for the CURRENT WEEK. >Example, starting on a Sunday and going through Saturday. >This week it would be Dec 27 - Jan 2. For the week of any date @d: ... WHERE order_date BETWEEN AddDate(@d, -DayOfWeek(@d)+1) AND AddDate(@d, 7-DayOfWeek(@d)) ... PB ----- ML wrote: > Hi All, > > trying to write some SQL that will give me records for the CURRENT WEEK. > > Example, starting on a Sunday and going through Saturday. > This week it would be Dec 27 - Jan 2. > > I am doing this so I can write a query that will show orders that are placed during the current week. > > Here is what I have, but this is showing from today for the next seven days. > > SELECT * FROM orders WHERE WEEK(NOW(), 7) = WEEK(orders.order_date, 7) > AND DATEDIFF(NOW(),orders.order_date) < 7; > > Would anyone have any advice? > > -Jason > > > > ------------------------------------------------------------------------ > > > No virus found in this incoming message. > Checked by AVG - www.avg.com > Version: 8.5.431 / Virus Database: 270.14.123/2592 - Release Date: 12/29/09 07:47:00 > > --------------060901080104030007080607--