Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting 04:30 into Seconds 2

Status
Not open for further replies.

fabby1

Technical User
Mar 9, 2004
206
GB
Hi

I have an input box that the users enters the number of minutes and seconds to include in a query.

I need to convert this date format 04:30c (4 minutes 30 seconds) into the seconds equivalent.

Is there a function that will do this ?

Thanks

Phil
 
Public Function CalcSecs(ByVal strMinsAndSecs As String) As Long

Dim intSeconds As Integer
Dim intMins As Integer

intSeconds = Right(strMinsAndSecs, InStr(1, strMinsAndSecs, ":") - 1)
intMins = Left(strMinsAndSecs, InStr(1, strMinsAndSecs, ":") - 1)

CalcSecs = (intMins * 60) + intSeconds

End Function

Please do not feed the trolls.....
 
Ed

Brilliant, thanks for the help

 
then, of course, you could get the conversion in a single step - IF (and ONLY if) the entry is forced to the h:m:s format.

Code:
? DateDiff("s", 0, CDate("0:4:30"))
 270

Which might be accomplished via a mask for the textbox.




MichaelRed


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top