SQL Server : datetime incorrect results -
using sql server 2008,
i have procedure follows:
select userid, name, company, languageid, coderegisteredwith, totalloggedinduration, region, isadmin, isrep, isretailer, isteamleader, [dateregistered] roundupacademy.dbo.userprofile with(nolock) (convert(smalldatetime, dateregistered, 120) >= convert(smalldatetime, '2013-1-1', 120) , (convert(smalldatetime, dateregistered, 120) <= convert(smalldatetime, '2013-8-8', 120)))
this works fine , shows results between dates.
however when expanding on query , more conditions follows:
select userid, name, company, languageid, coderegisteredwith, totalloggedinduration, region, isadmin, isrep, isretailer, isteamleader, [dateregistered] roundupacademy.dbo.userprofile with(nolock) userid not null or userid not '' , (@languageid = 0 or ([languageid] = @languageid )) , ((convert(smalldatetime, dateregistered, 120) >= convert(smalldatetime, @datereg, 120) , (convert(smalldatetime, dateregistered, 120) <= convert(smalldatetime, @dateend, 120))))
it seems date shows.
not sure problem other conditions fine.
any ideas?
replace
where userid not null or userid not ''
with
where (userid not null or userid not '')
otherwise records userid not null
or other conditions true.
Comments
Post a Comment