Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / November 2005

Tip: Looking for answers? Try searching our database.

Between Clause

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sherwood - 23 Nov 2005 22:59 GMT
Greetings,

I have the following formula in a query in order to retrieve records that
fall between two dates:

Between [Start Date] And [End Date]

However, when I run the query it doesn't include records for the end date
that I have keyed in.  I tried typing in "... [End Date] + 1", but I received
an error.  Is there anything else I can do to include records that include
the End Date?

Thanks in advance!
Signature

Sherwood

Rick Brandt - 23 Nov 2005 23:07 GMT
> Greetings,
>
[quoted text clipped - 9 lines]
>
> Thanks in advance!

Your criteria (if you enter only dates) is effectively looking for records
between midnight on the Start Date and midnight on the End Date which is why
records past midnight on the End Date are not included.

Adding one to the End Date is a common way to deal with this problem and it
should work.  What was the error you recieved?  You could try...

BETWEEN [Start Date] and DateAdd("d", 1, [End Date])

Signature

I don't check the Email account attached
to this message.     Send instead to...
RBrandt    at       Hunter      dot      com

fredg - 24 Nov 2005 00:34 GMT
> Greetings,
>
[quoted text clipped - 9 lines]
>
> Thanks in advance!

Your Date Field includes a Time value.
Therefore any data past 00:00:00 AM of the [EndDate] is not within the
Between [FromDate] And [EndDate] criteria.
Easiest work-around is to just add one day manually to the [EndDate]
when prompted, i.e. instead of entering 11/24/2005 enter 11/25/2005.

A better work-around would be to set
[FromDate]
and
[EndDate]
and their expected Datatype as query parameters in the Query Parameter
Dialog (Click Query + Parameter).
Then Change your criteria to:
Between [FromDate] and ([EndDate] + 1)

The best solution, if the Time of day is not necessary, is to run an
Update Query to remove the time value from the date:

Update YourTable Set YourTable.[DateField] = int([DateField]);

Then to make sure the time is not included in any new entries use
Date() instead of Now().
Signature

Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

OfficeDev18 - 24 Nov 2005 17:02 GMT
Are you sure the Start Date and End Date fields in the table are both Date
fields? If not, and you don't want to change them, use the CDate() function,
which will work on a Text field. Like so:
CDate([End Date])

>Greetings,
>
[quoted text clipped - 9 lines]
>
>Thanks in advance!

Signature

Sam

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.