By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,846 Members | 1,211 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,846 IT Pros & Developers. It's quick & easy.

Date as Parameter - Between 4/1 and 4/18 doesn't inlclude 4/18records

P: n/a
Hi -
I have had this problem MANY times and I just don't think I have the
best solution.

I am running a parameter query to retrieve records where work was
completed between 2 dates. The "completed date" field contains both
date and time (e.g., 11/4/07 15:44:00) and does need the time for the
data to be properly recorded.

That said, is it possible to format the parameter "Between [Enter
start date] and [Enter end date]" to enable the user to enter just the
dates when prompted rather than the date and time to retrieve all
records betwen the dates?

Currently, to retrieve records completed between 4/1/08 and 4/18/08 by
entering dates only, the user must enter 4/19/08 to retrieve a record
that was completed some time during 4/18/08.

I tried adding a field to the query:
JustDate: DateValue([CallDateAndTime]) with
Between [Start date] and [End Date]

and tried
Between DateValue([Start date] and Datevalue([End Date])

Got errors - couldn't run code - too complex...

I can do it if I say between [End date] +1, but there MUST be a
"proper" way!

Thanks
sara
Jun 27 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi Sara,

Instead of using Between try this:

Dim RS As DAO.RecordSet
Set RS = CurrentDB.OpenRecordset("Select * From ... Where Date1 >= #" &
txtStartDate & "# And Date2 <= #" & txtEndDate & "#")

And then retrieve whatever data you need from the recordset object

Or if you are using a parameter Query try this:

In the StartDate field enter this:
>=Forms!yourForm!txtStartDate

in the EndDate field enter this:

<=Forms!yourForm!txtEndDate

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #2

P: n/a

"sara" <sa*******@yahoo.comwrote in message
news:63**********************************@u69g2000 hse.googlegroups.com...
Hi -
I have had this problem MANY times and I just don't think I have the
best solution.

I am running a parameter query to retrieve records where work was
completed between 2 dates. The "completed date" field contains both
date and time (e.g., 11/4/07 15:44:00) and does need the time for the
data to be properly recorded.

That said, is it possible to format the parameter "Between [Enter
start date] and [Enter end date]" to enable the user to enter just the
dates when prompted rather than the date and time to retrieve all
records betwen the dates?

Currently, to retrieve records completed between 4/1/08 and 4/18/08 by
entering dates only, the user must enter 4/19/08 to retrieve a record
that was completed some time during 4/18/08.

I tried adding a field to the query:
JustDate: DateValue([CallDateAndTime]) with
Between [Start date] and [End Date]

and tried
Between DateValue([Start date] and Datevalue([End Date])

Got errors - couldn't run code - too complex...

I can do it if I say between [End date] +1, but there MUST be a
"proper" way!

Thanks
sara
Add 1 day to the entered end date. Date fields with time included are
greater than dates without time.

Between [Start Date] And DateAdd("d",1,[End Date])
Jun 27 '08 #3

P: n/a
On Thu, 17 Apr 2008 12:59:31 -0700 (PDT), sara <sa*******@yahoo.comwrote:
>Hi -
I have had this problem MANY times and I just don't think I have the
best solution.

I am running a parameter query to retrieve records where work was
completed between 2 dates. The "completed date" field contains both
date and time (e.g., 11/4/07 15:44:00) and does need the time for the
data to be properly recorded.

That said, is it possible to format the parameter "Between [Enter
start date] and [Enter end date]" to enable the user to enter just the
dates when prompted rather than the date and time to retrieve all
records betwen the dates?

Currently, to retrieve records completed between 4/1/08 and 4/18/08 by
entering dates only, the user must enter 4/19/08 to retrieve a record
that was completed some time during 4/18/08.

I tried adding a field to the query:
JustDate: DateValue([CallDateAndTime]) with
Between [Start date] and [End Date]

and tried
Between DateValue([Start date] and Datevalue([End Date])

Got errors - couldn't run code - too complex...

I can do it if I say between [End date] +1, but there MUST be a
"proper" way!

Thanks
sara
What does "between" mean in Access? The help file is not very helpful.
However, reading between the lines suggests that between means "greater than or
equal to " and "less than" (>= and <). That means that in Access, 'between'
means including first value but not including last value.

From a dictionary: "Thus in the sentence The bomb landed between the houses,
the houses are seen as points that define the boundaries of the area of impact
(so that we presume that none of the individual houses was hit)." To me this
is and <.
Jun 27 '08 #4

P: n/a
On Apr 17, 4:11*pm, Rich P <rpng...@aol.comwrote:
Hi Sara,

Instead of using Between try this:

Dim RS As DAO.RecordSet
Set RS = CurrentDB.OpenRecordset("Select * From ... Where Date1 >= #" &
txtStartDate & "# And Date2 <= #" & txtEndDate & "#")

And then retrieve whatever data you need from the recordset object

Or if you are using a parameter Query try this:

In the StartDate field enter this:
=Forms!yourForm!txtStartDate

in the EndDate field enter this:

<=Forms!yourForm!txtEndDate

Rich

*** Sent via Developersdexhttp://www.developersdex.com***
Thanks very much. I was thinking that it could be done without the >=
or whatever, but I understand it can't. I'm all set.
Jun 27 '08 #5

P: n/a
On Apr 17, 4:28*pm, "paii, Ron" <n...@no.comwrote:
"sara" <saraqp...@yahoo.comwrote in message

news:63**********************************@u69g2000 hse.googlegroups.com...


Hi -
I have had this problem MANY times and I just don't think I have the
best solution.
I am running a parameter query to retrieve records where work was
completed between 2 dates. The "completed date" field contains both
date and time (e.g., 11/4/07 15:44:00) and does need the time for the
data to be properly recorded.
That said, is it possible to format the parameter "Between [Enter
start date] and [Enter end date]" to enable the user to enter just the
dates when prompted rather than the date and time to retrieve all
records betwen the dates?
Currently, to retrieve records completed between 4/1/08 and 4/18/08 by
entering dates only, the user must enter 4/19/08 to retrieve a record
that was completed some time during 4/18/08.
I tried adding a field to the query:
JustDate: *DateValue([CallDateAndTime]) with
Between [Start date] and [End Date]
and tried
Between DateValue([Start date] and Datevalue([End Date])
Got errors - couldn't run code - too complex...
I can do it if I say between [End date] +1, but there MUST be a
"proper" way!
Thanks
sara

Add 1 day to *the entered end date. Date fields with time included are
greater than dates without time.

Between [Start Date] And DateAdd("d",1,[End Date])- Hide quoted text -

- Show quoted text -

Thanks very much. I was thinking that it could be done without the >=
or whatever, but I understand (now) it can't. I'm all set.
Jun 27 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.