SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


finding gaps between termination date and next enrollment date and filter by gap >= 45 days for...


finding gaps between termination date and next enrollment date and filter by gap >= 45 days for year 2013

Author
Message
Tammy-274861
Tammy-274861
SSC-Enthusiastic
SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)

Group: General Forum Members
Points: 105 Visits: 177
Hi Lynn!

That is a good question. I was assuming that if the enrollment date is for instance 2/1/2013, that's when the enrollment starts and if termination date is on 12/31/2013, that day is still counted as being enrolled, but I'm not sure if it's actually so. I would say yes, so then We have to add 1 day, correct?

I will have to confirm on Monday.

Sorry for not having a definitive answerSad

I will review the explanation of your code, I really appreciate you tsking the time to help me!!!

I hsve found you and autoexcrement to be so helpful!!!

Thank you so much!!! :-D


Tammy
autoexcrement
autoexcrement
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1156 Visits: 889
Apologies that I misunderstood what you needed. Hopefully Lynn will be able to see you to the finish line. Smile


"If I had been drinking out of that toilet, I might have been killed." -Ace Ventura
Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)

Group: General Forum Members
Points: 96494 Visits: 38983
Tammy-274861 (7/12/2014)
Hi Lynn!

That is a good question. I was assuming that if the enrollment date is for instance 2/1/2013, that's when the enrollment starts and if termination date is on 12/31/2013, that day is still counted as being enrolled, but I'm not sure if it's actually so. I would say yes, so then We have to add 1 day, correct?

I will have to confirm on Monday.

Sorry for not having a definitive answerSad

I will review the explanation of your code, I really appreciate you tsking the time to help me!!!

I hsve found you and autoexcrement to be so helpful!!!

Thank you so much!!! :-D


Tammy


Well, I am going with my experience with insurance and say the termination date is the last day of coverage.

Did you also read my explanation regarding the ID you said was 46 and was actually 45 when you look at the dates knowing (or assuming) what are dates of coverage and what aren't.

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Tammy-274861
Tammy-274861
SSC-Enthusiastic
SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)

Group: General Forum Members
Points: 105 Visits: 177
Hi Lynn and autoexcrement!

@autoexcrement, thank you so much for your time in helping me!!! :-D

@Lynn, yes, I saw your explanation, and regarding the 46 days it does make sense what you are saying and that's what I will go by!

So by changing the code to the last one you posted to account for leap year, that should make it work for any working year I use, correct?

Thanks a lot for such quick replies!!!! w00t

Tammy
Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)

Group: General Forum Members
Points: 96494 Visits: 38983
Tammy-274861 (7/12/2014)
Hi Lynn and autoexcrement!

@autoexcrement, thank you so much for your time in helping me!!! :-D

@Lynn, yes, I saw your explanation, and regarding the 46 days it does make sense what you are saying and that's what I will go by!

So by changing the code to the last one you posted to account for leap year, that should make it work for any working year I use, correct?

Thanks a lot for such quick replies!!!! w00t

Tammy


Yes, now that I programmatically calculate the number of days in the year it will work for any working year you use.

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Tammy-274861
Tammy-274861
SSC-Enthusiastic
SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)

Group: General Forum Members
Points: 105 Visits: 177
Good morning, Lynn!!! :-D


I'm happy to say it works like a charm!!!!

Your explanation is also really useful so I can understand what is going on.

I have a final question, what are you using the dayslapsed for?

I see it's the different between numdays and daysinyear, but is it being used or is this an extra check?

Thanks a lot for all your help with my issue!!!

Tammy
Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)

Group: General Forum Members
Points: 96494 Visits: 38983
Not really using it. Most of the columns returned by me are just for FYI. You should adjust the code as needed for your application.

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Tammy-274861
Tammy-274861
SSC-Enthusiastic
SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)

Group: General Forum Members
Points: 105 Visits: 177
Lynn,

Thank you so much for all your help!

I will mark your last query as the solution to my problem!!! w00t


I really appreciate all your time invested in helping me and your quick responses.

Take care of yourself there!!!!


Tammy
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search