I am trying to create a SQL stored procedure with a date range parameter to be used in a Sage Intelligence report. One old procedure uses the following:
CREATE PROCEDURE [dbo].[TJWEEK]
-- Add the parameters for the stored procedure here
@S_Date@ date, @E_Date@ date
with a where statement as folllows:
WHERE
CAST(CAST(RTRIM(OESHDT.TRANDATE) AS VARCHAR)AS DATE) >= @S_Date@ AND
CAST(CAST(RTRIM(OESHDT.TRANDATE) AS VARCHAR)AS DATE) <= @E_Date@
I have added this to a new stored procedure for a different client but I cannot get it to execute. When I parse the statements, I get "Commands completed successfully." But when I try to execute in SQL, I get "Operand type clash: int is incompatible with date."
What am I missing??
Any help would be appreciated.