PC Review


Reply
Thread Tools Rate Thread

Continuous Dates

 
 
=?Utf-8?B?Sm9obg==?=
Guest
Posts: n/a
 
      28th Oct 2003
I have a table that list a person for every month that they had insurance coverage. There is no standard beginning month and no standard ending month. There is one record for each month they were effective with a begin and end date. For example:
John Doe 1/1/03 1-31-03
John Doe 2-1-03 2-28-03
John Doe 4-1-03 4-30-03
Jane Smith 4-1-03 4-30-03
Jane Smith 5-1-03 5-31-03

I need to run a query that returns only members that have continuous dates over s specified time. i.e. Members effective for any continuous 12 month span regardless of begin or end dates.
Any help on this would be greatly appreciated.
 
Reply With Quote
 
 
 
 
Joe
Guest
Posts: n/a
 
      28th Oct 2003
John,

Don't know if this is the best way, but this may help:

1. Add a field called Month(EndDate)
2. Create a new query that sums the Month field per
person.
3. If field is greater than 78 (1+2+3+4...12) than the
person has been active for at least one year.
4. You can limit this by placing 78 as the criteria.

Hope this helps!


>-----Original Message-----
>I have a table that list a person for every month that

they had insurance coverage. There is no standard
beginning month and no standard ending month. There is
one record for each month they were effective with a
begin and end date. For example:
>John Doe 1/1/03 1-31-03
>John Doe 2-1-03 2-28-03
>John Doe 4-1-03 4-30-03
>Jane Smith 4-1-03 4-30-03
>Jane Smith 5-1-03 5-31-03
>
>I need to run a query that returns only members that

have continuous dates over s specified time. i.e.
Members effective for any continuous 12 month span
regardless of begin or end dates.
>Any help on this would be greatly appreciated.
>.
>

 
Reply With Quote
 
Dale Fye
Guest
Posts: n/a
 
      28th Oct 2003
Not necessarily true if their insurance lapsed and they restarted.

--
HTH

Dale Fye


"Joe" <(E-Mail Removed)> wrote in message
news:043401c39d93$63da4c70$(E-Mail Removed)...
John,

Don't know if this is the best way, but this may help:

1. Add a field called Month(EndDate)
2. Create a new query that sums the Month field per
person.
3. If field is greater than 78 (1+2+3+4...12) than the
person has been active for at least one year.
4. You can limit this by placing 78 as the criteria.

Hope this helps!


>-----Original Message-----
>I have a table that list a person for every month that

they had insurance coverage. There is no standard
beginning month and no standard ending month. There is
one record for each month they were effective with a
begin and end date. For example:
>John Doe 1/1/03 1-31-03
>John Doe 2-1-03 2-28-03
>John Doe 4-1-03 4-30-03
>Jane Smith 4-1-03 4-30-03
>Jane Smith 5-1-03 5-31-03
>
>I need to run a query that returns only members that

have continuous dates over s specified time. i.e.
Members effective for any continuous 12 month span
regardless of begin or end dates.
>Any help on this would be greatly appreciated.
>.
>



 
Reply With Quote
 
John Vinson
Guest
Posts: n/a
 
      28th Oct 2003
On Tue, 28 Oct 2003 12:38:05 -0800, "Joe"
<(E-Mail Removed)> wrote:

<posting a reply to a reply, sorry!>

>I have a table that list a person for every month that
>they had insurance coverage. There is no standard
>beginning month and no standard ending month. There is
>one record for each month they were effective with a
>begin and end date. For example:
>>John Doe 1/1/03 1-31-03
>>John Doe 2-1-03 2-28-03
>>John Doe 4-1-03 4-30-03
>>Jane Smith 4-1-03 4-30-03
>>Jane Smith 5-1-03 5-31-03
>>
>>I need to run a query that returns only members that

>have continuous dates over s specified time. i.e.
>Members effective for any continuous 12 month span
>regardless of begin or end dates.


A rather snarky Subquery (which migh be REALLY slow) should work:

SELECT MemberName, StartDate
FROM yourtable
WHERE (SELECT Count(*) FROM yourtable AS X
WHERE X.MemberID = yourtable.MemberID
AND X.StartDate >= DateAdd("m", -12, Yourtable.StartDate)) = 12;


John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public

 
Reply With Quote
 
Brian Camire
Guest
Posts: n/a
 
      29th Oct 2003
As a variation on John Vinson's suggestion that would also handle cases
where the begin and end date for each month aren't necessarily the first and
last day of the month, you might try something like this:

1. Create a query (say named Query1) that lists the records that mark the
beginning of a minimum period (in months) that is completely covered. The
SQL might look something like this:

PARAMETERS [Minimum Period] Long;
SELECT
[Your Table].[Member Name],
[Your Table].[Begin Date],
[Your Table].[End Date]
FROM
[Your Table]
INNER JOIN
[Your Table] AS Self
ON
[Your Table].[Member Name] = Self.[Member Name]
WHERE
Self.[Begin Date]>=[Your Table].[Begin Date]
AND
Self.[Begin Date]<DateAdd("m",[Minimum Period],[Your Table].[Begin Date])
GROUP BY
[Your Table].[Member Name],
[Your Table].[Begin Date],
[Your Table].[End Date]
HAVING
Sum([Self].[End Date]-[Self].[Begin Date]+1)
>=DateAdd("m",[Minimum Period],[Your Table].[Begin Date])-[Your

Table].[Begin Date];

This assumes the "Begin Date" and "End Date" have no time-of-day component,
and that there are no overlaps.

2. Create a second query that selects the distinct members from Query1.
The SQL might look something like this:

SELECT DISTINCT
[Query1].[Member Name]
FROM
[Query1]



"John" <(E-Mail Removed)> wrote in message
news:BA3BF132-2D97-4141-A873-(E-Mail Removed)...
> I have a table that list a person for every month that they had insurance

coverage. There is no standard beginning month and no standard ending
month. There is one record for each month they were effective with a begin
and end date. For example:
> John Doe 1/1/03 1-31-03
> John Doe 2-1-03 2-28-03
> John Doe 4-1-03 4-30-03
> Jane Smith 4-1-03 4-30-03
> Jane Smith 5-1-03 5-31-03
>
> I need to run a query that returns only members that have continuous dates

over s specified time. i.e. Members effective for any continuous 12 month
span regardless of begin or end dates.
> Any help on this would be greatly appreciated.



 
Reply With Quote
 
Brian Camire
Guest
Posts: n/a
 
      29th Oct 2003
On second thought, I think the HAVING clause in Query1 should read:

HAVING
Sum(IIf([Self].[End Date] + 1 > DateAdd("m", [Minimum Period], [Your
Table].[Begin Date]), DateAdd("m", [Minimum Period], [Your Table].[Begin
Date]), [Self].[End Date] +1) - [Self].[Begin Date])
= DateAdd("m", [Minimum Period], [Your Table].[Begin Date]) - [Your
Table].[Begin Date];

"Brian Camire" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> As a variation on John Vinson's suggestion that would also handle cases
> where the begin and end date for each month aren't necessarily the first

and
> last day of the month, you might try something like this:
>
> 1. Create a query (say named Query1) that lists the records that mark the
> beginning of a minimum period (in months) that is completely covered. The
> SQL might look something like this:
>
> PARAMETERS [Minimum Period] Long;
> SELECT
> [Your Table].[Member Name],
> [Your Table].[Begin Date],
> [Your Table].[End Date]
> FROM
> [Your Table]
> INNER JOIN
> [Your Table] AS Self
> ON
> [Your Table].[Member Name] = Self.[Member Name]
> WHERE
> Self.[Begin Date]>=[Your Table].[Begin Date]
> AND
> Self.[Begin Date]<DateAdd("m",[Minimum Period],[Your Table].[Begin Date])
> GROUP BY
> [Your Table].[Member Name],
> [Your Table].[Begin Date],
> [Your Table].[End Date]
> HAVING
> Sum([Self].[End Date]-[Self].[Begin Date]+1)
> >=DateAdd("m",[Minimum Period],[Your Table].[Begin Date])-[Your

> Table].[Begin Date];
>
> This assumes the "Begin Date" and "End Date" have no time-of-day

component,
> and that there are no overlaps.
>
> 2. Create a second query that selects the distinct members from Query1.
> The SQL might look something like this:
>
> SELECT DISTINCT
> [Query1].[Member Name]
> FROM
> [Query1]
>
>
>
> "John" <(E-Mail Removed)> wrote in message
> news:BA3BF132-2D97-4141-A873-(E-Mail Removed)...
> > I have a table that list a person for every month that they had

insurance
> coverage. There is no standard beginning month and no standard ending
> month. There is one record for each month they were effective with a

begin
> and end date. For example:
> > John Doe 1/1/03 1-31-03
> > John Doe 2-1-03 2-28-03
> > John Doe 4-1-03 4-30-03
> > Jane Smith 4-1-03 4-30-03
> > Jane Smith 5-1-03 5-31-03
> >
> > I need to run a query that returns only members that have continuous

dates
> over s specified time. i.e. Members effective for any continuous 12 month
> span regardless of begin or end dates.
> > Any help on this would be greatly appreciated.

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Dates in If Then statements in Continuous Forms bamrak@gmail.com Microsoft Access Form Coding 6 7th Feb 2007 06:05 PM
Continuous dates and time =?Utf-8?B?U3RvbmxleW9o?= Microsoft Excel Charting 1 27th Jan 2006 09:49 PM
Formula for Continuous Services Dates pvbridges Microsoft Excel Worksheet Functions 1 19th Jun 2005 01:51 AM
Continuous forms - add data between two dates Gary Beale via AccessMonster.com Microsoft Access Form Coding 9 18th May 2005 09:15 PM
Excel 2003 Non-continuous dates Peter Microsoft Excel Charting 1 24th Jan 2004 04:05 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:21 AM.