Solved

# How to Get total minutes between two hours

Posted on 2016-11-22
26 Views
Hi,

How can get the total minutes between two hours for ex. one person get in at 11:53 h and exit at 12:10 h from one place. In this case the difference is 17 minutes.

best regards
0
Question by:rflorencio
• 2

LVL 48

Expert Comment

ID: 41897328
HJI,

pls try
``````        DateTime a = new DateTime(2010, 05, 12, 11, 53, 00);
DateTime b = new DateTime(2010, 05, 12, 12, 10, 00);
Console.WriteLine(b.Subtract(a).TotalMinutes);
``````
Regards
0

LVL 17

Accepted Solution

Pawan Kumar Khowal earned 250 total points
ID: 41897329
Try..

``````Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim a As DateTime = "2016/01/01 11:53"
Dim b As DateTime = "2016/01/01 12:10"
Dim minutesDiff As Integer = DateDiff(DateInterval.Minute, a, b)
End Sub
``````

Output

17 minutes
0

LVL 49

Assisted Solution

Gustav Brock earned 125 total points
ID: 41897415
No points please, and not that it may matter in your case, but note that TotalMinutes returns a decimal value of minutes when (sub)seconds are present, while DateDiff returns an integer value based on the Minute component of the two date values.

/gustav
0

LVL 48

Assisted Solution

Rgonzo1971 earned 125 total points
ID: 41897420
you could use then
``````        DateTime a = new DateTime(2010, 05, 12, 11, 53, 00);
DateTime b = new DateTime(2010, 05, 12, 12, 10, 00);
Console.WriteLine(Math.Truncate(b.Subtract(a).TotalMinutes));
``````
0

## Featured Post

### Suggested Solutions

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.