Solved

Checking a range of dates in Access

Posted on 2012-04-09
9
210 Views
Last Modified: 2012-04-09
How would I check for all records where Data_A is between April 1, 2011 and December 2, 2011 and no records before April 1, 2011 exists.
0
Comment
Question by:morinia
  • 4
  • 3
  • 2
9 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37823698
select * from
tableX
where data_A >=#4/1/2011# and data_A <=#12/2/2011#
0
 

Author Comment

by:morinia
ID: 37823729
capricorn1

Does that query ensure that there is no record that is less than 4/2/2011 at all?  If a member has two records one 3/1/2011 and another one 5/1/2011.  I do not want to pull this member.
0
 
LVL 9

Expert Comment

by:macarrillo1
ID: 37823743
Then you need a query like:

select * from
YourTable
where data_A > #4/1/2011# and data_A < #12/2/2011#
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 400 total points
ID: 37823774
ohh, try this, you need to change  "recordID" with the actual field for the record ID

select * from
tableX
where data_A >=#4/1/2011# and data_A <=#12/2/2011#
and exists(select T.recordID from tableX where T.date_A< #4/1/2011)=false
0
 
LVL 9

Expert Comment

by:macarrillo1
ID: 37823779
If you want to exclude any member with more than one date you can do
a count on the members ID and exclude records with more than one for the count
as follows:


select MemberID, MemberName, count(*) as Ct from
Yourtable
where data_A > #4/1/2011# and data_A < #12/2/2011# and Ct=1
Group by MemberID, MemberName
0
 
LVL 9

Assisted Solution

by:macarrillo1
macarrillo1 earned 100 total points
ID: 37823818
Another way to do that is:

select * from
YourTable Y
where Y.data_A > #4/1/2011# and Y.data_A < #12/2/2011#
and Y.MemberID Not in(select X.MemberID from YourTable X where X.date_A< #4/2/2011)
0
 

Author Comment

by:morinia
ID: 37823820
Capricorn1,

I have not used access in a while.  I am on Access 2007.  Where do I go to enter the SQL version of the query?
0
 
LVL 9

Expert Comment

by:macarrillo1
ID: 37823829
In the query Wizard you select the SQL view.
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 400 total points
ID: 37823834
open a new query
from ribbon
Create > Query Design
Close the Show Table window
click on SQL view from the ribbon or right click on the empty space for the "tables" and select SQL view
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
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…

861 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