Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Query by Intervals within Date Range

Posted on 2001-08-08
8
Medium Priority
?
471 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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
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
 
LVL 54

Accepted Solution

by:
nico5038 earned 400 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
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…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Suggested Courses

971 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