• Status: Solved
• Priority: Medium
• Security: Public
• Views: 178

# Time to Resolve

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
titanium123
• 2
1 Solution

Commented:
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
``````
and call it in cell:
=hdiff(Start Date, End Date)
0

Author Commented:
Thanks als315 that works just pefect
0

Author Commented:
Great solution
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.