Solved

Checking a range of dates in Access

Posted on 2012-04-09
9
207 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 119

Expert Comment

by:Rey Obrero
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
 
LVL 119

Accepted Solution

by:
Rey Obrero 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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 119

Assisted Solution

by:Rey Obrero
Rey Obrero 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now