Solved

Query by Intervals within Date Range

Posted on 2001-08-08
8
456 Views
Last Modified: 2008-02-26
Table:
Start Date, Stop Date
If a Stop Date is Null, the record is active still.

User Selects:
1. Report Period (week, quarter), for this example week.
2. The Interval (month, quarter, year), for this example month
3. The Range of Start Dates (ie. 1/1/00 to 6/1/00)

Output (could be by row or column):
Period:        1/29/00|2/5/00|2/12/00|2/19/00|2/26/00|...6/8/00
Percent Active:PA     |PA    |PA     |PA     |PA     |...PA

Where PA = the % of active records at the Interval.The PA % = (Count(Active Records)/Count(Active + Inactive Records)) FOR Starts withing the specified Week!

In this example:
Starts from 1/29/00 to 2/4/00 would be measured to find the PA at the 1 month mark. 2/5 to 2/11, 2/12 to 2/19 etc.

Active record is one where the stop date IS NULL or the (stop date - start date)>Interval (In this case one month).
An Inactive Record = (stop date - start date)<Interval
0
Comment
Question by:douglaskarr
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 6

Expert Comment

by:PsychoDazey
ID: 6364914
I dont understand you're question.  Are you asking how to write the entire query you need or just how to tell it to look between the dates?
0
 
LVL 54

Expert Comment

by:nico5038
ID: 6365059
Nice piece of work to do douglaskarr!

I solved a similar problem with:
1) A module that "generates" the measuring points (week, month,quarter) and writes them to a (temp) table.
2) A module that returns all "hits" on one measuring point. (For weeks every "hit" translates in a table row with the hit-weeknumber) Here the enddate is used as NZ(enddate,#2999-12-31#) to make sure they hit.
3) A crosstable query that links the generated periods (as "master") to the created rows from 2). (The module is executed for all periods, but there can be periods without hits!)

Lost track or do you see the logic of this approach ?

Nic;o)
0
 

Author Comment

by:douglaskarr
ID: 6365315
PsychoDazey:  I believe it's a series of queries to get the result.  The most difficult thing for me to figure out is generating the date ranges (start date + interval...) to populate the table.

Nico:  I understand the logic - let me do some work and generate some follow up questions.
0
 
LVL 6

Expert Comment

by:PsychoDazey
ID: 6365358
"INSERT INTO table1 SELECT * FROM table2 WHERE datefield > #" & me![startdate] & "# AND < #" & me![stopdate] & "#"
you could also use the between keyword.
you have to remember to enclose the dates in #'s
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 54

Accepted Solution

by:
nico5038 earned 100 total points
ID: 6365481
Small remark PsychoDazey, the " > AND < " is seen by access as TWO compares. Using BETWEEN as only ONE !

This insert is not "matching" my 2) comment as it should insert additionally the period (week/month/quarter) and a NZ should be used for the NULL enddate !

Nic;o)
0
 
LVL 6

Expert Comment

by:PsychoDazey
ID: 6365536
Hence my comment on using the between.
As Douglas stated, it will probably be a series of questions to walk him all the way through this, by this statement I am sensing he is fairly new to vba.  My next step would have been to introduce the IsNull() function (my personal preference over the Nz)
0
 

Author Comment

by:douglaskarr
ID: 6423468
Wow.  I let this one go for a while.  Please let me review and get some testing underway.  
0
 
LVL 27

Expert Comment

by:Asta Cu
ID: 6907067
Please update the expert here who have so willingly stepped in to help you, since much time has passed since your last comments, and Email notifications may not have been generated to the participating experts here due to some problems at that time.  If you've been helped, accept the respective question by that expert to grade and close it.

Somewhat off-topic, but important.

****************************** ALERT********************************
WindowsUpdate - Critical Update alert March 28, 2002 from Microsoft
http://www.microsoft.com/technet/treeview/default.asp?url=/technet/security/bulletin/ms02-015.asp
Synopsis:
Microsoft Security Bulletin MS02-015  
28 March 2002 Cumulative Patch for Internet Explorer
Originally posted: March 28, 2002
Summary
Who should read this bulletin: Customers using Microsoft® Internet Explorer
Impact of vulnerability: Two vulnerabilities, the most serious of which would allow script to run in the Local Computer Zone.
Maximum Severity Rating: Critical
Recommendation: Consumers using the affected version of IE should install the patch immediately.
Affected Software:
Microsoft Internet Explorer 5.01
Microsoft Internet Explorer 5.5
Microsoft Internet Explorer 6.0

Thought you'd appreciate knowing this.
":0)
Asta
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now