Finding the Time Difference between two given dates


finding the Time Difference between two given dates

How to find the Time Difference between two given dates?


DateTime dt1 = DateTime.Now;
DateTime dt = DateTime.Now.AddHours(-26);
dt = dt.AddMinutes(-11);
TimeSpan tSpan = dt1.Subtract(dt); // Time Span value in which the difference will contain in terms of days, hours and minutes
Int64 diff = tSpan.Days * 60 * 60 + tSpan.Hours * 60 + tSpan.Minutes;
MessageBox.Show(diff.ToString()); // Actual difference in total minutes.


Related Articles

More articles: Date validation Difference between dates Time difference

Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: