Home Forums SQL Server 2005 T-SQL (SS2K5) finding gaps between termination date and next enrollment date and filter by gap >= 45 days for year 2013 RE: finding gaps between termination date and next enrollment date and filter by gap >= 45 days for year 2013

  • awww....so far away. Sorry and take care there!

    I am looking at your solution, sorry to bother again, but can you explain what you are doing here:

    sum(datediff(day,case when ENROLLMENTDATE < dateadd(year,@WorkingYear - 1900,0) then dateadd(year,@WorkingYear - 1900,0) else ENROLLMENTDATE end,case when TERMINATIONDATE >= dateadd(year,@WorkingYear - 1900 + 1,0) then dateadd(year,@WorkingYear - 1900 + 1,-1) else TERMINATIONDATE end) + 1) as NumDays

    Also, I just ran the query with the prod data that I had in a temp table, the following scenario went through, but it shouldn't since there are 46 days between 2013-10-16

    and 2013-12-01:

    UniversalMemberIDEnrollmentDateTerminationDate

    1920DESSA 2011-12-01 2013-02-28

    1920DESSA 2013-03-012013-10-16

    1920DESSA 2013-12-012199-12-31

    The only thing I changed on your query is this <= 45.

    I don't understand why would that one go though?

    Thank you so much, Lynn!!!! 😀