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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sql query to find activy times that cross time periods?

Status
Not open for further replies.

fenris

Programmer
May 20, 1999
824
CA
I have a program that collects activity duration data in the form of an activity start date (and time) to it's end date (and time). For example activity A started 09/23/2002 10:48 am and ended 09/23/2002 1:21 pm.

I need to be able to construct a sql query that captures the activity durations between a specific time period (Say 09/23/2002 12am to 09/24/2002 12am) but I need to capture durations that overlap the artifical boundries (Say 09/23/2002 11pm to 09/24/2002 2am).

The database is access 2000 and I need to grab the records that fall between the startDate and endDate as well as the records that have an end or start point on or within the time period. Also, each record has two columns, startTime and endTime.

I am not even sure how to go about this. I think it would look something like this:

SELECT * FROM tableA WHERE tableA.startTime Between startDate AND endDate

SELECT * FROM tableA WHERE tableA.endTime Between startDate AND endDate

NOTE: startDate and endDate are the actual time periods to search for

Thanks.



Troy Williams E.I.T.
fenris@hotmail.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top