Hi
I have 6 DropDownList and 1 button in my page
1-DDLYearStart that I bind it from database and show years
2-DDLMonthStar that I bind it from database and show Months
3-DDLDayStar I bind it from database and show Days
4-DDLYearEndthat I bind it from database and show years
5-DDLMonthEnd that I bind it from database and show Months
6-DDLDayEnd I bind it from database and show Days
I have House_p table in database that save users product's information with Date Column
now I want when I click on btnsearch it show product's information in datalist1 that i select
startdate from DDLYearStar,DDLMonthStar,DDLDayStart
and ENdDate DDLYearEnd,DDLMonthEnd,DDLDayEnd
I mean i.e if i select date from DDLYearStar,DDLMonthStar,DDLDayStart Like
2012-08-27(start date)
and select date from DDLYearEND,DDLMonthEND,DDLDayEND
2012-09-27(end date)
it show Product's information that their date column's value are between 2012-08-27 and 2012-09-27 (date that I select from DropDownLists)
SO I wrote below SP
create procedure [dbo].[SearchSEDate]
@Year int,
@month int,
@day int,
@YearE int,
@monthE int,
@dayE int
AS
BEGIN
select Name,BehCode,Date from House_p
WHERE
[Date] between
(DATEPART(YEAR,[Date]) = @Year
AND DATEPART(MONTH,[Date]) = @Month
AND DATEPART(DAY,[Date]) = @Day)
AND
(DATEPART(YEAR,[Date]) = @YearE
AND DATEPART(MONTH,[Date]) = @MonthE
AND DATEPART(DAY,[Date]) = @DayE)
END
But below error happen
Msg 102, Level 15, State 1, Procedure SearchSEDate, Line 14
Incorrect syntax near '='.
Is SP right?
Thanks alot