Tech
Forums
Jobs
Books
Events
Videos
Conference
Annual Conference
Bcrypt
Ai Conference
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
3
Answers
Time Span Diffrences Problem
Ask a question
Ask a question
Upload Source Code:
Select only zip and rar file.
Vishwas Kadamannaya
13y
2k
1
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
Post
Reset
Cancel
Answers (
3
)
Next Recommended Forum
Extract data from One dataGrid into another DataGrid.
Timeout error