Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
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 August 1st, 2006, 07:37 AM
Registered User
Join Date: Aug 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to find a date range between another date rang

I am in the process of trying to find out whether a date range falls between another date range and need help.

I have a table that lists the following:

Service Date End Date + 30 days - 30 days

06/04/04 9/2/04 7/4/04 5/4/04
9/25/04 12/24/04 7/4/04 5/4/04
9/29/03 10/29/06 2/2/04 12/4/03

And so on. I wanted to run a query to find out whether the range of (Service Date And End Date) fell within the range of (+30 days And - 30 Days).

Can someone please help.

Old August 3rd, 2006, 08:04 AM
Authorized User
Join Date: Dec 2005
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts

This will work. I chose to call the columns

"Start" "End" "Minus30" and "Plus30"

1. Make a query in design view
2. Save it
3. Double click each of the four fields to a column in the query design grid to add them to the query.
4. In the 'field' cell of the next column, type the following expression:

Expr1: IIf(([Start]>=[Minus30]) And ([End]<=[Plus30]),"Within the range","Not within the range")

Note the unusual spelling of "If" - it has two i's then one f.

Second term is what's returned if the expression is true (I chose a text) and the third term is what's returned if the expression is false i.e. if the service dates are not within the other range.
Old August 3rd, 2006, 09:50 AM
pjm pjm is offline
Authorized User
Join Date: Jul 2006
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts

Unless I'm missing something, you should be able to just use the expression:

([Start] between [Minus30] and [Plus30]) and ([End] between [Minus30] and [Plus30])


Similar Threads
Thread Thread Starter Forum Replies Last Post
find days per month in a date range rojer MySQL 1 June 5th, 2007 07:36 PM
Date Range Flipflop SQL Language 6 November 25th, 2005 08:36 AM
Need Help With Date Range rpainter Crystal Reports 0 June 20th, 2005 01:01 PM
Help with Date Range PacMed Access 1 February 1st, 2005 12:30 PM
Date Range mrideout BOOK: Beginning ASP.NET 1.0 0 January 2nd, 2005 07:18 PM

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