PC Review


Reply
 
 
kirkm
Guest
Posts: n/a
 
      2nd Jul 2009

Is there a command - or easy way to add minutes and seconds (rather
than converting everything to seconds etc.) ?

Thanks - Kirk
 
Reply With Quote
 
 
 
 
kirkm
Guest
Posts: n/a
 
      4th Jul 2009
Answering my own question!
Did no one esle know, or was it so obvious as to be a silly
question ?

Anyway this seems to work, but there maybe some glitch
not envisaged. Any comments, criticisms welcome!

--

Function AddTimes(ByVal t1, t2)
'Adds MINS and SECS
' format "02:50" , "03 45", "4:33" etc

Dim t1s, t2s, tt
t1s = Split(t1, " ")
If UBound(t1s) <> 1 Then t1s = Split(t1, ":")
t2s = Split(t2, " ")
If UBound(t2s) <> 1 Then t2s = Split(t2, ":")
tt = TimeSerial(0, t1s(0), t1s(1)) + TimeSerial(0, t2s(0), t2s(1))

If Val(Format(tt, "hh")) = 0 Then
AddTimes = Format(tt, "nn:ss")
Else
AddTimes = Format(tt, "hh:nn:ss")
End If
End Function
--


I wanted it to handle various Minutes and Seconds formats and
it doesn't check for bad input as there shouldn't be any !

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding Total Running Time from Begining and Ending Time david.tiberia@publix.com Microsoft Access Form Coding 2 14th Feb 2006 08:54 PM
Adding time to date-time formatted cell =?Utf-8?B?dGF3dHJleShyZW1vdmUgdGhpcyAgKUBwYWNpZmlj Microsoft Excel Misc 4 12th Aug 2005 10:53 PM
Elapsed Time for Productivity / Adding back time for Lunch Breaks =?Utf-8?B?RXJpY1RleA==?= Microsoft Access VBA Modules 1 1st Feb 2005 04:30 PM
formula for adding time to time eg 90min to 6.30am =?Utf-8?B?Vmlja2lqbzYw?= Microsoft Excel Misc 4 31st Aug 2004 11:54 AM
Time delay/lapse when adding days to a time value =?Utf-8?B?amF2YXRvcGlh?= Microsoft Dot NET Framework 1 13th Aug 2004 12:28 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:55 AM.