conversion faild when converting date time from charachter sting
Create proc searchData
@StartDate datetime, @EndDate datetime
asDeclare @SQLQuery as nvarchar(2000)SET @SQLQuery ='SELECT * from Employee Where (1=1)' If (@StartDate is not NULL) AND (@EndDate is not NULL) Set @SQLQuery = @SQLQuery + ' And (JoinDate BETWEEN '+ @StartDate +' AND '+@EndDate+')'Exec (@SQLQuery)
JoinDate found in table Employee as datetime
but when i make stored procedure as following
it work in formate dd/mm/yyyy and this is what i need
ALTER proc [dbo].[searchData]
@StartDate datetime
@EndDate datetime,
as