Need to display the difference of two columns

Posted by Kondapallisrinivas under ASP.NET on 10/25/2013 | Points: 10 | Views : 991 | Status : [Member] | Replies : 3
Hello All

Gridview1--> Contains four columns(ID,Name,Start date,End date)

I need the difference of start date and end date into text box.

Note: The grid contains only one record.

Regards
Srinivas Kondapalli




Responses

Posted by: Bandi on: 10/25/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Hi,
While selecting data from database itself get the difference of those two dates
SELECT ID,Name,[Start date],[End date], DATEDIFF( DD, [Start date],[End date]) DiffInDays
FROM tableName


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Kondapallisrinivas, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 10/25/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Hi,
      DateTime StartDt = Convert.ToDateTime(gdvEmp.Rows[0].Cells[2].Text);
DateTime EndDt = Convert.ToDateTime(gdvEmp.Rows[0].Cells[3].Text);
TimeSpan span = EndDt.Subtract(StartDt);
txtGrdData.Text = span.Days.ToString(); // You can get the difference in hours, days, years and so on


Reference for getting difference between two dates
http://www.overpie.com/aspnet/articles/csharp-calculate-difference-time-between-two-dates

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Kondapallisrinivas, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 10/25/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Click on "Mark as Answer " if you solved the issue; otherwise post us back

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Kondapallisrinivas, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response