Date and time range question

G

Guest

I'm trying to figure out how to get this to work and am having a lot of
problems. I have a form that users enter a start date and time and an enter
a end date and time. From those four form values, I'm trying to run a query
against a table where this table has a date column, a start_time column, and
a stop_time column. I want the results to show records say from 6am on 6/11
through 11am on 6/13 but I can't get this to work out right; I'm having
issues trying to get all the records from the 6/12 date in the middle. It
seems that this would have to be a three criteria line query to account for
the start date (with a start time constraint), middle date (showing all
time), and the end date (with a end time constraint). I've gotten the
beginning and end dates to work (so a 6/12 to 6/13 query with time
constraints) to work but I'm having problems accounting for the middle date
showing all time records. Here's the sql I have so far if it helps:

SELECT IMAGING_FOLDER_T.INDEX_DT, IMAGING_FOLDER_T.INDEX_START_TME,
IMAGING_FOLDER_T.INDEX_STOP_TME
FROM IMAGING_FOLDER_T INNER JOIN IMAGING_BATCH_T ON
IMAGING_FOLDER_T.BATCH_NM = IMAGING_BATCH_T.BATCH_NM
GROUP BY IMAGING_FOLDER_T.INDEX_DT, IMAGING_FOLDER_T.INDEX_START_TME,
IMAGING_FOLDER_T.INDEX_STOP_TME
HAVING
(((IMAGING_FOLDER_T.INDEX_DT)=[forms]![frmDocsIndexedDuringTimeRange]![Date1])
AND
((IMAGING_FOLDER_T.INDEX_START_TME)>=[forms]![frmDocsIndexedDuringTimeRange]![Time1]))
OR
(((IMAGING_FOLDER_T.INDEX_DT)=[forms]![frmDocsIndexedDuringTimeRange]![Date2])
AND
((IMAGING_FOLDER_T.INDEX_STOP_TME)<=[forms]![frmDocsIndexedDuringTimeRange]![Time2]));

Please help as I'm still trying to get this to work. I imagine I'm just
missing something with how to do an expression for this middle date part; the
expression columns in a query I'm a little weak at.
 
G

Guest

Please forget my stupidity. I didn't see I was using an equals sign in the
less than/greater than compares on the third criteria.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top