Link to home
Start Free TrialLog in
Avatar of Ridgejp
RidgejpFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Select Results on a Rolling Time Period

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
ASKER CERTIFIED SOLUTION
Avatar of Peos John
Peos John
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ridgejp

ASKER

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
Can you provide some sample data and expected result?
Avatar of Ridgejp

ASKER

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

WHERE invoiceDate >= now() - INTERVAL 21 DAY
Avatar of Ridgejp

ASKER

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