I have the following query:
DECLARE @Month int
DECLARE @Year int
set @Month = 2
set @Year = 2004
Declare @MonthStartDate datetime
declare @MonthEndDate datetime
set @MonthStartDate = 'select DATEADD(month,@Month-1,DATEADD(year,@Year-1900,0))'
set @MonthEndDate = 'select DATEADD(day,-1,DATEADD(month,@Month,DATEADD(year,@Year-1900,0)))'
return @MonthStartDate , @MonthEndDate
But it returns:
"Conversion failed when converting date and/or time from character string."
What's wrong here?