Hi all
i have two combo box where i added all the months name's first 3 letters(e.g. Jan, Feb etc.)
and another combo box which is having all the years from 2005-2012
Now i wrote the below query to find the result between 2 months of a year
but it's not giving me the output.
Please tell me where i am going wrong
select DatePart(MM,FromDate) as Month,Sum(Amount) as Amount
from SuppReport where DatePart(MM,FromDate) between
DATEPART(MM,CAST('Jan'+ '2005' AS datetime) and DATEPART(MM,CAST('Dec'+ '2005' AS datetime)
and CONVERT(VARCHAR(4),
DateName(YEAR,FromDate))='2005' Group By DatePart(MM,FromDate)
In this query i am trying to convert month name to month number.
but showing error
Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'and'.