Find out what Weekday we are then do something based on it

RCMetrics

Board Regular
Joined
Oct 28, 2005
Messages
95
Hi,

I do reporting based on a table that has sales by date.

I run my query on Mondays for the previous week (sunday to saturday)

this is the formula used to set the time frame wanted in my query:
(on the date field in table)

>=(Date()-9) And <=(Date()-3)

Which gives me "on mondays" the proper numbers and all.

What I would like is to be able to get the same results if I have to re-run something but later in the week

Say the table had something missing or corrections were made...
How to I avoid making changes to the query and get the formula to be smart enough to understand that if we are "thursday" to go backward 3 days and then do >=(Date()-9) And <=(Date()-3)

It would need to understand that if we are Sunday or Monday, business as usual... just get the past 7 days...

but on any other day... since the current week is not over, to give only results for the previous week...sunday to saturday.

Any ideas?
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Perhaps this <a href ="http://www.mrexcel.com/board2/viewtopic.php?t=184972"> thread</a> can help.
 
Upvote 0
Hi

Here's an example of getting the date for the previous Monday, and the Sunday that's just gone:

DateAdd("d",Now(),0-(DatePart("w",Now())-1)) AS SundayJustGone, DateAdd("d",[SundayJustGone],-6) AS LastMonday;

Hope that helps
Martin
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,434
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top