Click here to Skip to main content
15,896,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to fill grid by selecting two dates.
data should between two selected dates. i have little idea

WHERE CreatedDate between @date1 AND @date2

Tell me how can i get data.
Posted
Comments
Anele Ngqandu 22-Nov-12 7:28am    
you mean you want a sql statement?
Yasir Farooq 22-Nov-12 7:34am    
yes.
just storedprocedur

hi i Think This Code helps you

SELECT * FROM TABLE

WHERE DATE BETWEEN
Convert(varchar,CreatedOn,103)=CONVERT(varchar,ISNULL('01/02/2012',CreatedOn),103)
AND Convert(varchar,CreatedOn,103)=CONVERT(varchar,ISNULL('05/05/2012',CreatedOn),103)


"103" stands BRITISH/FRENCH FORMAT



for more search this link http://www.sql-server-helper.com/tips/date-formats.aspx[^]
 
Share this answer
 
v2
if i understood your question correctly then you may use this to get the answer

SQL
DECLARE @date1 datetime,@date2 datetime
SET @date1='2012-07-20'
SET @date2='2012-07-25'
Select ColName from TableName WHERE ColName between @date1 AND @date2


you can give the date range in @date1 and in @ date2 from your textbox or anywhere else
 
Share this answer
 
Hi please try this sql statement

C#
SELECT *
FROM TABLE 
WHERE CreateDate 
BETWEEN '01/01/2009' AND '01/31/2009'











Vote if it helps....
 
Share this answer
 
Comments
Yasir Farooq 22-Nov-12 8:03am    
Can i pass parameter on date like?
BETWEEN @dateFrom AND @dateTo
Anele Ngqandu 22-Nov-12 8:13am    
Yes you can...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900