Solved

Filtering Sat Sun from Microsoft Acccess

Posted on 2009-07-13
4
318 Views
Last Modified: 2013-11-28
I have an issue.  I am running a daily report using this to only get yesterdays numbers.  >=Date()-1.  But on Mondays I need fridays numbers cause there are no Sunday numbers.  is there an easy way of filtering out Sat and Sun?
SELECT dbo_SOSO.WrittenBy, dbo_vwsnInvoiceLineSales.ExtendedPrice, dbo_ARInvoice.InvoiceDate
FROM (dbo_ARInvoice INNER JOIN dbo_SOSO ON dbo_ARInvoice.SONumber = dbo_SOSO.SONumber) INNER JOIN dbo_vwsnInvoiceLineSales ON dbo_ARInvoice.InvoiceNumber = dbo_vwsnInvoiceLineSales.InvoiceNumber
WHERE (((dbo_ARInvoice.InvoiceDate)>=Date()-1));

Open in new window

0
Comment
Question by:gotti777
  • 2
4 Comments
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 24839528
WHERE dbo_ARInvoice.InvoiceDate >= (Date() - Choose(Weekday(Date()), 2, 3, 1, 1, 1, 1, 1));
0
 

Author Closing Comment

by:gotti777
ID: 31602812
well it seem to work i will keep an eye on it. not sure what the 2,3,1,1,1,1, but it worked
0
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 24839648
It is like a switch/case statement.  You are evaluating the first argument which is the week day of date() that results in values 1 - 7.

The next 7 arguments representing the value returned for each result of week day.

2 == on Sunday, subtract 2 days to Friday
3 == on Monday, subtract 3 days to Friday
1 == everything else (including Saturday), subtract 1 day to get to a week day.

Hope that makes sense.

Best regards,
Kevin
0
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 24839697
In case it wasn't clear, Sunday is week day 1 and Monday is week day 2 which is why it is 2, 3, 1, 1, 1, 1, 1 as it is going in order of the day of week numbers for Sunday - Saturday.
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question