Solved

Time to Resolve

Posted on 2014-04-26
3
142 Views
Last Modified: 2014-04-27
I have 2 cells with a opened time and a closed time i want to minus opened from closed and get the total number of hours. each cell is formated like this 2013/05/31 19:49:17. When i minus one from the other the days done show just the hours. Also need error checking in the equation so I can get an average time from a pivot table. I am using excel 2013
0
Comment
Question by:titanium123
  • 2
3 Comments
 
LVL 39

Accepted Solution

by:
als315 earned 500 total points
ID: 40025397
Excel has DATEDIF function, but it can return only days, months and years, so if you can use macros, add this function to new module:
Public Function hdiff(S As Range, E As Range) As Double
If IsNull(S) Or S = 0 Or IsNull(E) Or E = 0 Then
    hdiff = 0
Else
    hdiff = DateDiff("s", S, E) / 3600 'Calculate difference in seconds and convert to decimal hours
End If
End Function

Open in new window

and call it in cell:
=hdiff(Start Date, End Date)
0
 

Author Comment

by:titanium123
ID: 40025444
Thanks als315 that works just pefect
0
 

Author Closing Comment

by:titanium123
ID: 40025445
Great solution
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now