A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

"Between...and" operator problem



 
 
Thread Tools Display Modes
  #1  
Old October 5th, 2009, 03:20 PM posted to microsoft.public.access.gettingstarted
Big Point
external usenet poster
 
Posts: 1
Default "Between...and" operator problem

When I run a query using the "Between...and" operator with dates, it returns
the correct "Beginning Month" but one month short of the "Ending Month"
specified. For Jan to Dec 2008 specified in the data input form it returns
Jan to Nov 2008. This happens for any range of months. Is there a property
option I can't find?
  #2  
Old October 5th, 2009, 03:40 PM posted to microsoft.public.access.gettingstarted
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default "Between...and" operator problem

Post the SQL of your query by opening in design view, click on VIEW - SQL
View, highlight all, copy, and paste in a post.
--
Build a little, test a little.


"Big Point" wrote:

When I run a query using the "Between...and" operator with dates, it returns
the correct "Beginning Month" but one month short of the "Ending Month"
specified. For Jan to Dec 2008 specified in the data input form it returns
Jan to Nov 2008. This happens for any range of months. Is there a property
option I can't find?

  #3  
Old October 5th, 2009, 06:00 PM posted to microsoft.public.access.gettingstarted
fredg
external usenet poster
 
Posts: 4,386
Default "Between...and" operator problem

On Mon, 5 Oct 2009 07:20:02 -0700, Big Point wrote:

When I run a query using the "Between...and" operator with dates, it returns
the correct "Beginning Month" but one month short of the "Ending Month"
specified. For Jan to Dec 2008 specified in the data input form it returns
Jan to Nov 2008. This happens for any range of months. Is there a property
option I can't find?


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] = DateValue([DateField]);

Then make sure the time is not included in any new entries, i.e. use
Date() instead of Now().
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
  #4  
Old October 5th, 2009, 06:12 PM posted to microsoft.public.access.gettingstarted
John W. Vinson
external usenet poster
 
Posts: 18,261
Default "Between...and" operator problem

On Mon, 5 Oct 2009 07:20:02 -0700, Big Point
wrote:

When I run a query using the "Between...and" operator with dates, it returns
the correct "Beginning Month" but one month short of the "Ending Month"
specified. For Jan to Dec 2008 specified in the data input form it returns
Jan to Nov 2008. This happens for any range of months. Is there a property
option I can't find?


Correct the error in your query criteria.

For help doing so please post the criteria that you are using; open the query
in design view, select View... SQL, and post the SQL text here.
--

John W. Vinson [MVP]
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:07 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.