472,328 Members | 1,556 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,328 software developers and data experts.

Seconds as hh:mm:ss

Dear friends

I need to format seconds as hh:mm:ss. I see a lot of coding transforming
seconds to hh:mm:ss. Somebody know a short way?

Regards Able
Nov 20 '05 #1
6 2985
Try the following:

-----------------
Dim objTime As New TimeSpan(0, 0, 1234)
Debug.WriteLine(objTime.Hours & ":" & objTime.Minutes & ":" &
objTime.Seconds)
-----------------

There's probably better and shorter ways to do this, but I can't think of
any at the minute.

Note, you'll need to handle cases where the duration goes over one day
(86400 seconds)

HTH,

Trev.

"Able" <ab**@epost.no> wrote in message
news:NM******************@news2.e.nsc.no...
Dear friends

I need to format seconds as hh:mm:ss. I see a lot of coding transforming
seconds to hh:mm:ss. Somebody know a short way?

Regards Able

Nov 20 '05 #2
Thanks Trev

Able

"Trev Hunter" <hu*********@hotmail.com> skrev i melding
news:uP**************@TK2MSFTNGP10.phx.gbl...
Try the following:

-----------------
Dim objTime As New TimeSpan(0, 0, 1234)
Debug.WriteLine(objTime.Hours & ":" & objTime.Minutes & ":" &
objTime.Seconds)
-----------------

There's probably better and shorter ways to do this, but I can't think of
any at the minute.

Note, you'll need to handle cases where the duration goes over one day
(86400 seconds)

HTH,

Trev.

"Able" <ab**@epost.no> wrote in message
news:NM******************@news2.e.nsc.no...
Dear friends

I need to format seconds as hh:mm:ss. I see a lot of coding transforming
seconds to hh:mm:ss. Somebody know a short way?

Regards Able


Nov 20 '05 #3
* "Able" <ab**@epost.no> scripsit:
I need to format seconds as hh:mm:ss. I see a lot of coding transforming
seconds to hh:mm:ss. Somebody know a short way?


\\\
Dim ts As TimeSpan = TimeSpan.FromSeconds(23423423)
MsgBox(ts.Hours.ToString() & ":" & ts.Minutes.ToString() & ":" & ts.Seconds.ToString())
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
I believe you get the same answer if you initialize your timespan to 9023
which indicates that the answer for 23423423 isn't correct.

At least one would notice the extra hours with:
MsgBox(((ts.Days * 24) + ts.Hours).ToString & ":" &
ts.Minutes.ToString() & ":" & ts.Seconds.ToString())
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
* "Able" <ab**@epost.no> scripsit:
I need to format seconds as hh:mm:ss. I see a lot of coding transforming
seconds to hh:mm:ss. Somebody know a short way?
\\\
Dim ts As TimeSpan = TimeSpan.FromSeconds(23423423)
MsgBox(ts.Hours.ToString() & ":" & ts.Minutes.ToString() & ":" &

ts.Seconds.ToString()) ///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #5
or...

Dim secs As Long = 123456
Dim dt As New DateTime(secs * 10000D)
MsgBox(dt.ToString("HH:mm:ss"))

dominique
"Able" <ab**@epost.no> wrote in message
news:NM******************@news2.e.nsc.no...
Dear friends

I need to format seconds as hh:mm:ss. I see a lot of coding transforming
seconds to hh:mm:ss. Somebody know a short way?

Regards Able

Nov 20 '05 #6
little correction

*10000000D and not *10000D

dominique

"Dominique Vandensteen" <domi.vds_insert@tralala_tenforce.com> wrote in
message news:%2****************@tk2msftngp13.phx.gbl...
or...

Dim secs As Long = 123456
Dim dt As New DateTime(secs * 10000D)
MsgBox(dt.ToString("HH:mm:ss"))

dominique
"Able" <ab**@epost.no> wrote in message
news:NM******************@news2.e.nsc.no...
Dear friends

I need to format seconds as hh:mm:ss. I see a lot of coding transforming
seconds to hh:mm:ss. Somebody know a short way?

Regards Able


Nov 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: hikums | last post by:
Does anyone have a function to convert duration in seconds to a format hh:mm:ss Thanks.
2
by: D. Shane Fowlkes | last post by:
Here's a good one. I've been using an Excel spreadsheet for the past couple of years to calculate a file's Estimated Download Time based off of a...
14
by: Michael Barrido | last post by:
I have this for example: Dim iSeconds as int32 = 3600 '3600 seconds is one hour How do i convert it to "01:00:00" ? Please help. Thanks...
1
by: Jason Chan | last post by:
DateTime mydate = new DateTime(2006,1,1,0,0,0); string testStr = mydate.ToString("hh:mm:ss"); //return 12:00:00 mydate = new...
15
by: Jay Tee | last post by:
Hi, I have some code that does, essentially, the following: - gather information on tens of thousands of items (in this case, jobs running on...
1
by: Vishal Bhargava | last post by:
Is there an inbuilt library in Python which you can use to convert time in seconds to hh:mm:ss format? Thanks, Vishal
1
seshu
by: seshu | last post by:
Hi every body to morning my cousine has show his application and also his live db in that to sav the length of all the voice files he has saved in...
1
seshu
by: seshu | last post by:
Hi every body to morning my cousine has show his application and also his live db in that to sav the length of all the voice files he has saved in...
1
by: emajka21 | last post by:
I am using Visual Studios 2005 with C#. I have a time field that is stored in seconds. I want to display it as hours:minutes:seconds in a repeater...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
1
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.