Reputation: 183
I have a stored procedure like this:
alter procedure [dbo].[IBS_PodiumSummeryCount]
@locid integer=null
as
begin
SET NOCOUNT ON;
select sum(status_receved) as Receved, sum(status_parked) as Parked,
sum(status_requested) as Requested,sum(status_requestedinprocess) as Requestinprocess
from (select case when (status = 0 ) then 1 else 0 end as status_receved,
case when (status = 2) then 1 else 0 end as status_parked,
case when (status = 3) then 1 else 0 end as status_requested,
case when(status=4) then 1 else 0 end as status_requestedinprocess
from transaction_tbl where locid = @locid and status in (0,2,3,4)) a;
end
but i want to get last 24 hour data from my sql server..i added getdate() -1 in my where condition. so changed my stored procedure like this:
alter procedure [dbo].[IBS_PodiumSummeryCount]
@locid integer=null
as
begin
SET NOCOUNT ON;
select sum(status_receved) as Receved, sum(status_parked) as Parked,
sum(status_requested) as Requested,sum(status_requestedinprocess) as Requestinprocess
from (select case when (status = 0 ) then 1 else 0 end as status_receved,
case when (status = 2) then 1 else 0 end as status_parked,
case when (status = 3) then 1 else 0 end as status_requested,
case when(status=4) then 1 else 0 end as status_requestedinprocess
from transaction_tbl where locid = @locid and getdate()-1 and status in (0,2,3,4)) a;
end but now getting error like this: An expression of non-boolean type specified in a context where a condition is expected, near 'and'.
Upvotes: 0
Views: 571
Reputation: 8867
try with .. AND datetimetocompare between DATEADD(DAY, -1, GETDATE()) and GETDATE()
Upvotes: 1