Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Lorenzo Lee   on Sep 10 In MS Office Category.

  
Question Answered By: Candace Foster   on Sep 10

I think the best way to approach this would be to convert the number into
seconds then subtract then convert it back to H:M:S or HMS.

You could create two functions HMS2S to do the first two conversions and
s2HMS to do the third

Function HMS2S(sIVal As String) As Long
Dim lSeconds As Long
lSeconds = sIVal Mod 100
lSeconds = lSeconds + (Int(sIVal / 100) Mod 100) * 60
lSeconds = lSeconds + Int(sIVal / 10000) * 3600
hms2s = lSeconds
End Function

Function S2HMS(lSecs As Long) As String
S2HMS = lSecs Mod 60 _
+ (Int(lSecs / 60) Mod 60) * 100 _
+ Int(lSecs / 3600) * 10000
End Function

The functions must be in a module!!!

The entry in the cell is
=S2HMS(HMS2S(B4)-HMS2S(C4))

Share: 

 

This Question has 9 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Finding difference in time Or get search suggestion and latest updates.


Tagged: