Solved

Query by Intervals within Date Range

Posted on 2001-08-08
8
455 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

706 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

18 Experts available now in Live!

Get 1:1 Help Now