Select Results on a Rolling Time Period

Ridgejp
Ridgejp used Ask the Experts™
on
Hi,

I'm using PHP/MySQL to return data sets on a daily basis.

But what's the WHERE clause statement to extract results from a SELECT query perhaps on a rolling weekly, monthly or quarterly basis?

I'm asking so that the Select query returns a constant moving set of results set based on the data found in the database.

Jason
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Can you please give little more detail above the columns you have?

Do you want to fetch the data from the table based on any Date column you have?

Author

Commented:
Hi,

Yes so a typical query might look like: -

SELECT orderID, buyerName, BuyerAddress1, BuyerAddress2, BuyerAddress3, buyerCounty, buyerPCD, catID, quantity, totalPrice FROM salesuk WHERE invoiceDate >= "01/01/2017" ORDER BY DESC;

That type of query ... hope that helps?

J
SharathData Engineer

Commented:
Can you provide some sample data and expected result?

Author

Commented:
This is the code I was looking for, which produces a 21 rolling day view: -

WHERE invoiceDate >= now() - INTERVAL 21 DAY

Author

Commented:
Thanks for the prompt made me realise I knew enough to work it out!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial