Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
| Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 5th, 2005, 02:42 PM
Registered User
 
Join Date: Apr 2005
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default MS Access Between and And Operator

I am working on a database with date and time. I am trying to write a query to let the user select the start and end dates. However, the end date is not included in the query because the time is assumed to be 12 AM. How can I get the query to include the end date all the way to 11:59 PM?

 
Old April 6th, 2005, 07:09 AM
Friend of Wrox
 
Join Date: Sep 2003
Location: Salisbury, Wiltshire, United Kingdom.
Posts: 155
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to leehambly
Default

I would guess that you are getting "only up to and not including" the end date because you are passing a date into a date/time. Sorry if this is teaching you to suck eggs...

A date with no time component is dd/mm/yy 00:00:00 (ie: midnight on the day before dd/mm/yy)
To get a check for < end date (which includes the end day) - you will need to check for < dd+1/mm/yy 00:00:00 (ie: midnight on the dd/mm/yy)

So just add 1 to your end date criteria to push you to the end of the end day rather than the beginning of the end day.

ie: Between [start date] and ([end date] + 1)

OR set your date formats to be the same, unlikely your users will want to search by date/time though, isnt it?
 
Old April 6th, 2005, 09:32 AM
Registered User
 
Join Date: Apr 2005
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

When I tried Between [Enter Start Date] And ([Enter End Date]+1)
I got an error message saying that "The expression is typed incorrectly or is too complex to be evaluated." Is there another way to type in the expression that Access will accept?




 
Old April 6th, 2005, 09:46 AM
Friend of Wrox
 
Join Date: Jan 2005
Location: , , United Kingdom.
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think what Leehambly is trying to say is that when you are prompted for your dates you would include the next date. e.g. 01/01/01 to 02/01/01 would show all records between 01/01/01 00:00:00 and 02/01/01 00:00:00. A 24 hour period from midnight to midnight. You do not try to adjust your expression to include the +1.

If you really want to force a day ahead then use this exression to add + 1 day to the 'Enter Date To' parameter

Between [Enter Date From:] And DateAdd("d",1,[Enter Date To:])

Now you can type 01/01 to 01/01 and it still returns the whole period.

Hope it Helps,

Jon
 
Old April 6th, 2005, 11:13 AM
Registered User
 
Join Date: Apr 2005
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi again,

Between [Enter Date From:] And DateAdd("d",1,[Enter Date To:])

Seems to be working perfectly! Thanks for the info!!!

Doug





Similar Threads
Thread Thread Starter Forum Replies Last Post
Change the format of MS Excel Cells from MS Access hewstone999 Access VBA 0 March 7th, 2008 07:19 AM
Invalid operator for data type. Operator equals di Pusstiu SQL Server 2000 2 August 10th, 2007 04:51 AM
Database migration MS Access 2003 to MS SQL 2000 ayazhoda SQL Server 2000 3 April 23rd, 2007 11:38 AM
MS ACCESS 2003 FRONTEND AND MS SQL SERVER 2005 DB mohankumar0709 SQL Server 2005 3 March 23rd, 2007 12:48 AM
MS Data Grid control in ms access application roshla_p Access VBA 5 October 16th, 2006 02:37 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.