![]() |
Adding Time
Is there a command - or easy way to add minutes and seconds (rather than converting everything to seconds etc.) ? Thanks - Kirk |
Adding Time
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 ! |
All times are GMT +1. The time now is 05:41 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com