Tech
Forums
Jobs
Books
Events
Live
Interviews
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
3
Reply
Time Span Diffrences Problem
Vishwas Kadamannaya
Apr 5 2011 1:51 AM
2k
Reply
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
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
3
)
Next Recommended Forum
Extract data from One dataGrid into another DataGrid.
Timeout error