Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

MS Access Days of the week

Posted on 2013-12-31
2
Medium Priority
?
537 Views
Last Modified: 2013-12-31
I need to find all the dates in the last 6 weeks which fell on a Tuesday.  I've gone round and round so far, I can find which day a date is, but can't get the logic right to find all Tuesdays.  Thanx in advance.
0
Comment
Question by:NoGurru
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 21

Accepted Solution

by:
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP earned 2000 total points
ID: 39749341
Since you want all the data last 6 weeks I assume that means you need a query. And you want to filter the data to having data on Tuesday.

When you say the last 6 weeks I assume that means this week and the previous 5 weeks.
In my experience, the last 6 weeks (current week included) and the past six weeks (prior to  the current week)  are not the same.


To get the last full six weeks you will need to calculate the first day of the week for the date 5 weeks from today using:

dateadd("ww",-5,Date) - WeekDay(dateadd("ww",-5,Date)) + 1 ) 

Open in new window


For the current data of 12/31/2014 then:
? dateadd("ww",-5,Date) - WeekDay(dateadd("ww",-5,Date)) + 1
11/24/2013 

Open in new window


If you ran it on Friday 1/3/2014 is will still work:
? dateadd("ww",-5,#1/3/2014#) - WeekDay(dateadd("ww",-5,#1/3/2014#)) + 1
11/24/2013 

Open in new window


Now that you can select all the data within the range you add an additional where criteria to select only Tuesdays/ with:


AND (Weekday([Your Date])=3)

Putting it all together, here is a query using the orders table in the Northwind database

SELECT Orders.[Order ID], Orders.[Order Date], Weekday([Order Date]) AS DOW
FROM Orders
WHERE (((Orders.[Order Date]) Between (DateAdd("ww",-5,Date) - WeekDay(DateAdd("ww",-5,Date)) + 1 ) AND ((Weekday([Order Date]))=3));

Open in new window


It returns  all the order where the data is in the past 6 full weeks from the current date and the date is a Tuesday.
0
 

Author Closing Comment

by:NoGurru
ID: 39749362
Thank you for the fast feedback.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

598 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