now I am trying following query
ALTER PROCEDURE [dbo].[proc_GetUserRequests]
(
@EmpUserId INT,
@RequestTypeId INT,
@RequestStatusId INT=NULL,
@StartDate VARCHAR=NULL,
@EndDate VARCHAR=NULL
)
AS
BEGIN
SELECT Id, Username, SenderAddress, ReceiverAddress, AddedOn, ModifiedOn
FROM Requests
WHERE
EmpUserId = @EmpUserId
AND RequestTypeId=@RequestTypeId
AND RequestStatusId=(CASE WHEN @RequestStatusId IS NULL THEN RequestStatusId ELSE @RequestStatusId END)
AND AddedOn BETWEEN
CONVERT(DATETIME,CONVERT(VARCHAR(11),@StartDate,113)+'00:00:00',120)
AND
CONVERT(DATETIME,CONVERT(VARCHAR(11),@EndDate,113)+'23:59:59',120)
END
if I write
EXEC proc_GetUserRequests 6409,1,1,'2011-12-06'
I get error as
"The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value."
What might be going wrong?