Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query based on date

Status
Not open for further replies.

Costefran

Technical User
Jan 2, 2008
197
GB
Another one

I am trying to identify a clash of two records based on dates

As an example to explain lets say I have a car and and Record A shows
That between 20/01/2010 and 22/01/2010 my wife has arranged for a service

Record B shows
I then want to use my car from 19/01/2010 to 21/01/2010 so I run a query or other to check dates

So the reocrds look something like this
A
Start Date End Date Task Description
20/01/2010 22/01/2010 Arranged for service
B
Start Date End Date Task Description
19/01/2010 21/01/2010 Use Car

What would be the easiest way to compare the clash of dates via a query

Thanks again

 
Assuming you have a primary key field named ID and your table name is "tblNoName" try something like:
Code:
SELECT A.ID, B.ID, A.StartDate, B.StartDate, A.EndDate, B.EndDate, A.TaskDescription, B.TaskDescription
FROM tblNoName A , tblNoName B
WHERE A.ID <> B.ID AND A.StartDate<B.EndDate and A.EndDate>B.StartDate

Duane
Hook'D on Access
MS Access MVP
 
Thanks

I will try this and let you know how I get on
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top