Question Locked

MS Access Query, Date and Time Trouble

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Does anyone know how I can create a query that will let the user input a start date and an end date, and then show the results between specific, pre-determined times?

For example: I want the user to be able to enter 8/8/07, when asked for the start date. Then enter 8/9/07 when asked to enter the end date. After hitting enter, I want the results to return everything input into the table on 8/8/07 from 11:00am untill 11:00am on 8/9/07.

I believe it is possible to do what I need to do, but am not sure how to do it. I am sure there is an easy solution and I am just overlooking it.

Currently I have: Between [Enter START Date (m/d/yy)] And [Enter TODAY'S Date (m/d/yy)]:in the Criteria box when the query is in design view. I am getting all the correct dates but want to filter the time to show >=11:00am on the start, and <=11:00am on the end.

Any help on this would be greatly appreciated!

Thanks,
Jon

6 replies

by absolutely

Use those keywords to build your query.

(might be "date part" & "time part", I'm not logged into Windows at the moment)

by maevinn

The user can enter M/D/YY H:M AM and M/D/YY H:M PM to restrict the values.

by absolutely

Recording the time of the transaction doesn't seem to be a concern. Rather, the goal is to use only the dates entered, then append '11am' to the dates to define a range.

by tony hopkinson

Where TargetDate Between DateAdd('h',11,Startdate) and DateAdd('h',11,Enddate)

by ozi eagle

Hi,

Access has query commands [datefrom] and [dateto]. Now both go from 00:00. The from part is OK but the to part is midnight on the date specified, so you don't get that dates info.

To get the times you want you need to add the time, like this

[DateFrom] & " 11:00:00"
[DateTo] & " 11:00:00"

Herb

This discussion is closed to new replies.