Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Create procedure error

Author  Topic 

Julie19
Starting Member

32 Posts

Posted - 2012-06-29 : 11:38:06
I get the error"Operand type clash: date is incompatible with int" when I run the following procedure.

CREATE PROCEDURE GetSurvey
@startdate date,
@enddate date
AS
SELECT
cast(month(Completion_date)as varchar(2))
+'/'+
cast(day(Completion_date)as varchar(2))
+'/'+
cast(year(Completion_date)as char(4)) as Completion_Dt
,[Rep D]as Rep_ID

FROM dbo.XYZ as ABC
inner join
(select
max(year(Completion_Date)) as CurYr
,max(month(Completion_Date)) as CurMth
FROM dbo.XYZ) as Cur
on month(completion_date)=Cur.CurMth
and year(completion_date)=Cur.CurYr

Where [Survey Type] = '123'
and Completion_date >= @startdate and Completion_date < (@enddate + 1)
GROUP BY Completion_Date, [Rep ATTUID]
order by Completion_Date desc, [Rep ATTUID]

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-06-29 : 11:53:53
Change your WHERE clause to this:
...
WHERE
[Survey Type] = '123'
AND Completion_date >= @startdate
AND Completion_date < DATEADD(dd,1,@enddate)
...
Go to Top of Page

Julie19
Starting Member

32 Posts

Posted - 2012-06-29 : 13:05:42
Thank you
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-06-29 : 13:29:49
Very welcome .)
Go to Top of Page
   

- Advertisement -