[AccessD] Using Between in a query

McGillivray, Don DMcGillivray at ctc.ca.gov
Mon Aug 14 12:04:16 CDT 2017


It's probably better to change the comparison so that the value from the table doesn't include the time, rather than adding a day to the end of the range.  

Something like :

Int(TheDateFromTheTable) between StartDate and EndDate

The Int() function removes the time portion from the date, allowing you to use the actual range for the comparison.

If you add a day to the end of the range, any records dated at midnight of that additional day will be included in the results - not exactly what you want.



-----Original Message-----
From: AccessD [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Ryan W
Sent: Monday, August 14, 2017 9:35 AM
To: Access Developers discussion and problem solving <accessd at databaseadvisors.com>
Subject: Re: [AccessD] Using Between in a query

I should mention your interactive query could be "smart" and do [Enter your end date]+1 to add a full day to the logic.

On Mon, Aug 14, 2017 at 11:33 AM, Ryan W <wrwehler at gmail.com> wrote:

> When you do not enter a time, 00:00 is assume.  So "BETWEEN" 7/30/17 
> AND 7/31/17" means from 7/30/17 00:00 (midnight) until 7/31/17 00:00 
> (midnight) so it does not account for the full day ahead.  They would 
> need to enter
> 7/31/17 23:59 or 8/1/17
>
>
>
> On Mon, Aug 14, 2017 at 11:27 AM, Kaup, Chester < 
> Chester_Kaup at kindermorgan.com> wrote:
>
>> I have an interactive query where the user is asked to put in a start 
>> date and an end date. The query then uses the criteria of Between 
>> start date and end date. I am having a problem of some records not 
>> being retrieved. If the user puts in and end date of 7/31/2017 a 
>> record with a date of 7/31/2017 1:30PM is not retrieved. Does an end 
>> date of 7/31/2017 mean ending at 12:00 PM on 7/30/2017? I guess I may 
>> not be fully understanding the use of Between.
>> --
>> AccessD mailing list
>> AccessD at databaseadvisors.com
>> http://databaseadvisors.com/mailman/listinfo/accessd
>> Website: http://www.databaseadvisors.com
>>
>
>
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list