Hi All,
I have a datatable that contains travel details
TravelDate | Source | Destination | DepartureTime | ArrivalTime | Duration |
|
|
| 10:00:00 | 12:00:00 | 2 |
|
|
| 12:00:00 | 1:00:00 | -11 |
I am getting all the values in datatable except "Duration", I need to calculate duration based on Departure and Arrival Time .
I am using the below step to do that but some time it gives wrong values
Foreach(DataRow dr in dt.Rows)
{
TimeSpan ts1 = TimeSpan.Parse(dr["DepartureTime"].ToString()); TimeSpan ts2 = TimeSpan.Parse(dr["ArrivalTime"].ToString());
TimeSpan ts3 = ts2.Subtract(ts1);
dr["Duration"]=ts3.ToString();
}
In second row it gives wrong value . How to rectify this..
Thanks in Advance