Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi,


i'm have a table with 3 column(name, amt,date)

name amt date
moh 1000 28/06/2013
suj 2000 30/06/2031
ren 1500 02/07/2013


how to get the data between this two date i.e,(03/07/2013 and 25/06/2013)


i want to retrieve the data between above mention data?
Posted
Comments
jaideepsinh 2-Jul-13 2:51am    
You want code for code behind or sql.

SQL
select * from Table where Date between '06-25-2013' and '07-03-2013'


Please mark as answer if solve your problem.
 
Share this answer
 
v3
Hi,

you can try this out:

C#
 DataTable dt = new DataTable();
            dt.Columns.AddRange(new DataColumn[] { new DataColumn("Name", typeof(string)), new DataColumn("Amount", typeof(int)), new DataColumn("Date", typeof(DateTime)) });
            dt.Rows.Add(new object[] { "Sam", 1000, new DateTime(2013, 06, 12) });
            dt.Rows.Add(new object[] { "Derk", 2000, new DateTime(2013, 07, 1) });
            dt.Rows.Add(new object[] { "Rohan", 4000, new DateTime(2013, 08, 16) });

 string myfilter = "Date > #" + dt.Rows[1][2].ToString() + "# AND Date <=#" + dt.Rows[2][2].ToString() + "#";
dt.Select(myfilter);
            DataRow[] drTemp = dt.Select(myfilter);
            DataTable dtTemp = drTemp.CopyToDataTable();
 
Share this answer
 
v2

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