June 15, 2011 at 7:38 pm
When i previewing the reportgetting below error:
"Conversion failed when converting datetime from character string"
The query in the dataset1:
Select f1,f2,f3
from tablename
where date=@Year and date=@Monthname
dataset2:
select datepart(yyyy,date) from table
dataset3:
select datename(month,date) from table where datepart(yyyy,date)=@year
Thanks in advance
June 16, 2011 at 7:50 am
My first question is how can you have a single value equal to 2 different values?
where date=@Year and date=@Monthname
June 20, 2011 at 2:07 pm
srichaitya (6/15/2011)
When i previewing the reportgetting below error:"Conversion failed when converting datetime from character string"
The query in the dataset1:
Select f1,f2,f3
from tablename
where date=@Year and date=@Monthname
dataset2:
select datepart(yyyy,date) from table
dataset3:
select datename(month,date) from table where datepart(yyyy,date)=@year
Thanks in advance
Maybe try something like
Select f1,f2,f3
from tablename
where Year(date)=@Year and month(date)=@Monthname
what datatype is 'date' and what are @Year and @Monthname declared as?
June 21, 2011 at 5:26 am
Year can be integer and Month name can be varchar(20) , Please use DATEPART function while extracting out the specific Month/Year/Day out of it,
Make sure mangoes must be compared with mangoes...
Let me know if you need further claerifications.
June 21, 2011 at 5:46 am
I guess you are using Visual Studio to write the queries (dataset1 ...),
you can try SQL Server Management Studio here you can edit your queries easier and then paste them into Visual Studio (at least this is what I am doing).
If Month is a character (i.e. May, June) then you can use DateName funtion.
In which case the where clause can be as bellow:
DATEPART(yyyy,date) = @Year
AND DATENAME( MONTH, GETDATE() ) = @Monthname
Regards,
Iulian
June 22, 2011 at 8:18 pm
Thanks for all. .
I wrote the query like below.it works well
Select f1,f2,f3
from table
where depart(yyyy,date)=@year and datename(m,date)=@monthname
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply