Click here to Skip to main content
15,884,981 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Every one,

I am making aproject in c#. i want to show records in gridview.
In search panel i am show two date criteria (datefrom and dateto).
And on the page i am using two buttons ('prev date' and 'next date').
I want when user search records between two dates then firstly record should be show of single date that is 'DateFrom'.
and when user click on next button then next date's result should show in gridview.

and one more problem is that if i select 17/5/2012 in 'datefrom' and 22/5/2012 in 'dateTo'.
then if in database records are exist from 21/5/2012.
so how i show the only records of 21/5/2012 and then after click on next button next record will show between date of search dates.

please help me if any one have any idea.
Posted
Comments
Prasad_Kulkarni 25-May-12 3:55am    
You need to provide some thing which you've tried so far?

Hi Friend....

U can passs the selected date value as a paramenter into Stored procedure.
 
Share this answer
 
Comments
coolnavjot31 25-May-12 3:28am    
Arul thanks for reply but please read my problem carefully.
Prasad_Kulkarni 25-May-12 3:41am    
Please provide some example or reference.
Arul R Ece 25-May-12 4:12am    
SqlConnection con = new SqlConnection(constr);
con.Open();
SqlCommand cmd = new SqlCommand("taskreport", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@calledFor", "ByStatus");
cmd.Parameters.AddWithValue("@assignedto", "NULL");
cmd.Parameters.AddWithValue("@status", status);
cmd.Parameters.AddWithValue("@startime", strdate);
cmd.Parameters.AddWithValue("@endtime", enddate);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
gridreport.DataSource = ds;
gridreport.DataBind();
Arul R Ece 25-May-12 4:13am    
It is example for report between two dates
Not sure if I understood the question correctly, but perhaps you can use a static sql statement like:
SQL
SELECT ... 
FROM  YourTable 
WHERE DateColumn >= @start 
AND   DateColumn < @end

Regardless of the dates the query would always be the same. If you query:
- for a single date, for example @start = 25/5/2012, @end = 26/5/2012 (current date + 1)
- tomorrow, @start = 26/5/2012, @end = 27/5/2012 (current date + 1 and 2)
- for date range @start = 17/5/2012, @end = 22/5/2012
 
Share this answer
 
what are you tried is not well undrestand but what i understand according to it i am trying to give one solution i hope it will work.

SQL
SELECT ...
FROM  YourTable
WHERE DateColumn >= @start
AND   DateColumn < @end  and DateColumn in ( select top 1 DateColumn FROM  YourTable where DateColumn >= @start
AND   DateColumn < @end order by DateColumn  ) 


best of luck.
 
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