SSMS Stored procedure not showing records that fall on end date
<p>I have a stored procedure that takes in two parameters: start date (<code>@SDate</code>) and end date (<code>@EDate</code>), after which it outputs a summary of data between the two dates. </p>

<p>However, it does not show records that falls on the <code>@EDate</code>. </p>

<p>This is my code:</p>

<pre><code>DECLARE TidCursor SCROLL CURSOR
FOR 
    SELECT DISTINCT  
        A.TID, P.ProjGroup, A.Location, P.MainSubCon
    FROM 
        [PRT].[dbo].[Personnel] P,[PRT].[dbo].[Attendance] A 
    WHERE 
        A.TID = P.TID 
        AND (A.Timein BETWEEN @SDate AND @EDate) 
        AND (A.Timeout BETWEEN @SDate AND @EDate) 
        AND (A.Timein IS NOT NULL AND A.timeout IS NOT NULL)
    ORDER BY 
        A.TID ASC   

OPEN TidCursor      

FETCH NEXT FROM TidCursor INTO @rec1_Tid, @rec1_PG, @rec1_Loc, @rec1_MainSubCon
.
.
.

DECLARE AttnCursor SCROLL CURSOR FOR 
    SELECT TimeIn, TimeOut, Location 
    FROM Attendance
    WHERE TID = @rec1_Tid 
      AND (Timein BETWEEN @SDate AND @EDate) 
      AND (Timeout BETWEEN @SDate AND @EDate) 
      AND (Timein IS NOT NULL AND timeout IS NOT NULL)  
    ORDER BY TimeIn

-- variables used to check for multiple logins in the same day
SET @curDate = '';
SET @preDate = '';

OPEN AttnCursor         

FETCH NEXT FROM AttnCursor INTO @indt, @outdt, @inloc   

WHILE (@@FETCH_STATUS = 0)
BEGIN
   .
   .
   .

   FETCH NEXT FROM AttnCursor INTO @indt, @outdt, @inloc
END    -- END WHILE (@@FETCH_STATUS = 0)

-- Closes the cursor
CLOSE AttnCursor; 
DEALLOCATE AttnCursor;

FETCH NEXT FROM TidCursor INTO @rec1_Tid, @rec1_PG, @rec1_Loc, @rec1_MainSubCon

END -- END WHILE (@@FETCH_STATUS = 0)

-- Closes the cursor
CLOSE TidCursor; 
DEALLOCATE TidCursor;
</code></pre>