Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 1st, 2006, 07:37 AM
Registered User
Join Date: Aug 2006
Location: , , .
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.

Reply With Quote
  #2 (permalink)  
Old August 3rd, 2006, 08:04 AM
Authorized User
Join Date: Dec 2005
Location: , , .
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.
Reply With Quote
  #3 (permalink)  
Old August 3rd, 2006, 09:50 AM
pjm pjm is offline
Authorized User
Join Date: Jul 2006
Location: Boston, MA, USA.
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])

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 02:24 PM.

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