Avatar of Ridgejp
Ridgejp
Flag 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
PHPMySQL Server

Avatar of undefined
Last Comment
Ridgejp

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Peos John

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
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
Sharath S

Can you provide some sample data and expected result?
Ridgejp

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

WHERE invoiceDate >= now() - INTERVAL 21 DAY
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Ridgejp

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