Solved

Select dates of current and next week

Posted on 2006-11-20
2
435 Views
Last Modified: 2013-12-12
I have a database which has product codes and release dates.

I want to be able to select all items that have a release date that falls within the current week.

I want a seperate select which selects all items that have a release date that falls within the following week.

Is there a way to set up the mysql select for the dates to fall in a certain week?  Or will I have to use a date range instead?

Example of use:  SELECT * FROM products_table where  GET_WEEK(product_release_date) = CURRENT_WEEK.
0
Comment
Question by:baumli1
2 Comments
 

Author Comment

by:baumli1
ID: 17980311
Here is solution that I figured out:

Current Week:
SELECT WEEK(CURRENT_DATE(),2);

Next Week:
SELECT (WEEK(CURRENT_DATE(),2) + '1');


Current Week:
SELECT * FROM `products` WHERE WEEK(release_date,2) = WEEK(CURRENT_DATE(),2);


Next Week:
SELECT * FROM `products` WHERE WEEK(release_date,2) = (WEEK(CURRENT_DATE(),2) + '1');


The "2" in SELECT WEEK(CURRENT_DATE(),2); determines if the week starts with Sunday or Monday and if the year has 0-53 or 1-53 weeks.  In my cases, I chose 1-53 weeks, and week starts with a Sunday.

0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 0 total points
ID: 18097606
PAQed with points refunded
angelIII, page editor
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now