How can I find difference between two time intervals.
Like 13:45:26.836 – 14:24:18.473 which is of the format “Hour:Min:Sec:Millisecs”. Now i need to find the time difference between these two times.
How can i do this in C#.?
Thanks in advance.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Basically, what you need to do is put those time values into
DateTimestructures. Once you have your twoDateTimevariables, just subtract them from one another – the result is a variable of typeTimeSpan:TimeSpan has a ton of properties that get sets – the difference in all sorts of units, e.g. milliseconds, seconds, minutes etc. You can also just do a
.ToString()on it to get a string representation of the result. Inresult2, you’ll get something like this:Is that what you’re looking for?