Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select results from previous Sunday

Status
Not open for further replies.

tyutghf

Technical User
Apr 12, 2008
258
GB
My boss wants me to create a view for him that lists sales each week from Sunday.

So, on Sunday morning, the sales will be 0. As the day goes on, it will increase as sales come in.

By Saturday, this count should be quite high

But when he looks Sunday morning again, the count will reset to 0 and increase again throughout the week.

I'm not sure how on earth to go about this

SELECT product, count(id) FROM sales where dateSold >= Sunday

He wants a web page to show him this so we have php to help us, do we have date functions in mysql that we can use?

Thanks
 
Sorted, I used PHP to get the date instead of mess about with sql that I didn't know as he wanted the page creating quickly.

$previousSunday = date('Y-m-d', strtotime('previous sunday', strtotime($todaysDate)));

If anyone does know a mysql version I'd still be happy to learn it however.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top