Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Converting HH:MM:SS string to Seconds Integer

Posted on 2006-05-15
4
Medium Priority
?
802 Views
Last Modified: 2008-02-26
I need to covert a HH:MM:SS string to Seconds as Integer

Thanks
Dan
0
Comment
Question by:DigitalDan3
  • 3
4 Comments
 
LVL 14

Accepted Solution

by:
jake072 earned 2000 total points
ID: 16685730
Is the input as a string?  Is it always in the format HH:MM:SS ?

If so, then try something like this:

Dim iSeconds as Integer = strInput.SubString(0, 2) * 60 * 60 + strInput.SubString(3, 2) * 60 + strInput.SubString(6, 2)

Where strInput is the Input string, and is always HH:MM:SS...

So you could have something like (for input string):

00:00:01, 12:00:01, etc....

Let me know if you need further help.

Jake
0
 

Author Comment

by:DigitalDan3
ID: 16685956
What if the input was a date and time and I wanted to convert to seconds.  Is there not a Framework method to convert HH:MM:SS to seconds?
0
 
LVL 14

Expert Comment

by:jake072
ID: 16686023
Ok then,

Dim dteTime As DateTime = [Parse your string into a DateTime...]
Dim lngSeconds As Long = dteTime.Ticks * TimeSpan.TicksPerSecond

Voila!

Let me know if you need more help,

Jake

0
 
LVL 14

Expert Comment

by:jake072
ID: 16686055
Whoops!!!

Should've been a divide operation, not a multiplication!  My apologies!

Anyways, that will give you the seconds expressed by the date time...  (So it will also take into account the seconds for the date: "The value of this property [Ticks] is the number of 100-nanosecond intervals that have elapsed since 12:00 A.M., January 1, 0001")...  This may not be what you want, but there it is.

Jake
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question