?
Solved

How to Get total minutes between two hours

Posted on 2016-11-22
4
Medium Priority
?
70 Views
Last Modified: 2016-11-22
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
Comment
Question by:rflorencio
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 52

Expert Comment

by:Rgonzo1971
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);

Open in new window

Regards
0
 
LVL 30

Accepted Solution

by:
Pawan Kumar earned 1000 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

Open in new window


Output

17 minutes
0
 
LVL 51

Assisted Solution

by:Gustav Brock
Gustav Brock earned 500 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 52

Assisted Solution

by:Rgonzo1971
Rgonzo1971 earned 500 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));

Open in new window

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question