Question : Pay between 2 dates

I am trying to get the payroll where the check date is between 2 dates, but I’m getting 2 results. If I run it this way

declare @date1 datetime, @date2 datetime
set @date1 = '2010-07-17'
set @date2 = @date1 + 6
select @date1, @date2

The result of @date1 and @date2 is
2010-07-17 00:00:00.000      2010-07-23 00:00:00.000


(select sum(uprtrxam)
from UPR30300 a
      inner join UPR00100 b on a.employid = b.employid
where chekdate between @date1 and @date2)

I get 6482.49, but if I run it this way

(select sum(uprtrxam)
from UPR30300 a
      inner join UPR00100 b on a.employid = b.employid
where chekdate between '2010-07-17' and '2010-07-23')

I get 7724.86. Can someone tell me why I’m getting different results please? I know it’s probably obvious, but I can’t see it.

Answer : Pay between 2 dates

@rjackmanwyn - I am not suggesting taking them out for good.  What I am trying to do is eliminate the possibility that the JOIN is causing the issue and not something else.  My thoughts are remove all of the where clause except the BETWEEN <dates> and the JOIN to see the results between the two.  Isolate each filter by itself to further see what could be causing the issue.
Random Solutions  
 
programming4us programming4us