MySQL Forums
Forum List  »  Newbie

Re: Custom Defined Week/Date Range Help
Posted by: Peter Brawley
Date: January 31, 2017 01:58PM

When dayofweek( curdate() ) = 5, your current week is as your query says, when < 5 it's ...

where sales_date between curdate() - interval 6 - dayofweek(curdate()) day and curdate()

when 6 it's ...

where sales_date = curdate()

when 7 it's ...

where sales_date between curdate() - 1 day and curdate().

That logic will go easily into a case clause. One would think, though, that to make the results meaningful, you'd need to normalise the sums to per workday.

Options: ReplyQuote


Subject
Written By
Posted
Re: Custom Defined Week/Date Range Help
January 31, 2017 01:58PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.