Thats what i was telling. Fetch data from database into DataTable using your access method:
DataTable, say dt, looks something like:
-------------------------------------------
BookIssueId | ReturnDate | ActualReturnDate
-------------------------------------------
1 | 2012-09-12 | 2012-09-15
2 | 2012-09-05 | 2012-09-07
-------------------------------------------
Then add column "DifferenceDays" in dt:
dt.Columns.Add("DifferenceDays", typeof(int));
Then calculate difference days as below:
foreach (DataRow dr in dt.Rows)
{
DateTime date1 = DateTime.Parse(dr["ReturnDate"].ToString());
DateTime date2 = DateTime.Parse(dr["ActualReturnDate"].ToString());
TimeSpan ts = date2.Subtract(date1);
dr["DifferenceDays"] = ts.TotalDays.ToString();
}
Now set dt as grids datasource. Thats it!!! :)