Query parameter to just return weekdays

TylerTand

Registered User.
Local time
Today, 04:41
Joined
Aug 31, 2007
Messages
95
I am trying to write a query that looks at groups of records for averages and maximums but the records are only from Mon-Fri (Trading Days). I have a query that runs everyday and compares today's close to see if it is greater than the maximum close of the last 20 trading days. I want to use between date()-21 and date()-1. BUT this will include weekends where there is no data.

QUESTION: Is there a way to say between the last 20 trading days(Mon-Fri)?

I researched dateadd() and found one place were it says that "w" is used for weekday. http://www.database-design-2000.com/dateadd.htm BUT when I did a simple query to see if it would exlude the weekends it doesn't. I will have no data for the weekends but if I am doing an average of the last three days and this is run on Monday, it will only include Monday and not the previous Thursday and Friday. Thanks for your help:)
 
Use the weekday function and exclude the values for sat. and sun.
 
I don't see where in the function you would exclude Saturday and Sunday? Can you please give me an example of how to exclude these two days? I know that I want to exclude 1(default Sunday) and 7 (Saturday) but "days to exclude" is not part of the function. So how can this be done? I am trying to do this in the wizard but have some experience writing in SQL as well. Thanks for your help.
 

Users who are viewing this thread

Back
Top Bottom