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

Query between date and time

Status
Not open for further replies.

elevins

Technical User
Jan 24, 2005
18
I am wanting to query between a start date & time and an end date & time. Lets say I wanted all records between 2:00AM on 05/15/2005 and 4:25AM on 05/16/2005. How would query this to get ALL records in the middle of those times?
 
use

Between Date( ) And DateAdd("M", 3, Date( ))



Program Error
Programmers do it one finger at a time!
 
Between #2005-05-15 02:00:00# And #2005-05-16 04:25:00#

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
This is what I had before in the SQL view of my query.

SELECT SenLog.Date, SenLog.*, SenLog.Time
FROM SenLog
WHERE (((SenLog.Date) Between [Start Date] And [End Date]) AND ((SenLog.Time) Between [Start Time] And [End Time]));


I am using these dates as an example I would like it to be able to enter any relavent date or time when prompted

For an example this searches:

between 2:00am - 4:25am on 05/15/2005 and
between 2:00am - 4:25am on 05/16/2005

I would like to search:
between 2:00am on 05/15/2005 - 4:25am on 05/16/2005
 
Perhaps this ?
WHERE ((SenLog.Date + SenLog.Time) Between ([Start Date] + [Start Time]) And ([End Date] + [End Time]));

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I think PHV that...
"WHERE ((SenLog.Date + SenLog.Time) Between ([Start Date] + [Start Time]) And ([End Date] + [End Time]));"
...is on the right path but I am still not getting an output from it. I can put in values in correct spots and it will come up with zero results.

My worry is that the "(SenLog.Date + SenLog.Time)" is the problem.

IF you or anyone else has any suggestions I am still working on this problem.

Thanks
 
For me it's a database design issue:
why storing ONE DateTime value in TWO fields (SenLog.Date and SenLog.Time)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top