I am looking for how it is possible to calculate the difference in minutes for a date and time.

This example will cover the problem.

20091118 18:15
20091125 01:35

I know this is possible using Date functions and TimeSpan but trying to find examples but cant find an example of this problem.

I will be happy to solve this.

Thank you!

Recommended Answers

All 2 Replies

Subtract two dates.

DateTime d1 = DateTime.Parse("11/18/2009 18:15");
  DateTime d2 = DateTime.Parse("11/25/2009 01:35");

  TimeSpan ts = d2 - d1;
  Console.WriteLine("Seconds : {0} Minutes : {1}", ts.TotalSeconds, ts.TotalMinutes);

Thank you, that worked very well.

Subtract two dates.

DateTime d1 = DateTime.Parse("11/18/2009 18:15");
  DateTime d2 = DateTime.Parse("11/25/2009 01:35");

  TimeSpan ts = d2 - d1;
  Console.WriteLine("Seconds : {0} Minutes : {1}", ts.TotalSeconds, ts.TotalMinutes);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.