473,785 Members | 2,841 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3106
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.n o> wrote in message
news:NM******** **********@news 2.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*********@ho tmail.com> skrev i melding
news:uP******** ******@TK2MSFTN GP10.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.n o> wrote in message
news:NM******** **********@news 2.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.n o> 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.FromSe conds(23423423)
MsgBox(ts.Hours .ToString() & ":" & ts.Minutes.ToSt ring() & ":" & ts.Seconds.ToSt ring())
///

--
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.Day s * 24) + ts.Hours).ToStr ing & ":" &
ts.Minutes.ToSt ring() & ":" & ts.Seconds.ToSt ring())
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
* "Able" <ab**@epost.n o> 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.FromSe conds(23423423)
MsgBox(ts.Hours .ToString() & ":" & ts.Minutes.ToSt ring() & ":" &

ts.Seconds.ToSt ring()) ///

--
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.ToStr ing("HH:mm:ss") )

dominique
"Able" <ab**@epost.n o> wrote in message
news:NM******** **********@news 2.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_inser t@tralala_tenfo rce.com> wrote in
message news:%2******** ********@tk2msf tngp13.phx.gbl. ..
or...

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

dominique
"Able" <ab**@epost.n o> wrote in message
news:NM******** **********@news 2.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
17651
by: hikums | last post by:
Does anyone have a function to convert duration in seconds to a format hh:mm:ss Thanks.
2
2488
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 solid 50kbs connection (dial up). This is for a downloads page such as: http://www.drpt.virginia.gov/downloads/selectedcat.aspx?ID=12 The formula is basically this: =(((C4*1000*8)/50000)/84600)*1.1 (Estimate is calculated on a modem dial up connection of 50Kbs and transfer
14
4101
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 in advance!
1
2766
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 DateTime(2006,1,1,1,0,0) testStr = mydate.ToString("hh:mm:ss"); //return 01:00:00 I want "00:00:00" instead of "12:00:00", what is going wrong?
15
6633
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 a compute cluster) - store the information as a list (one per job) of Job items (essentially wrapped dictionaries mapping attribute names to values)
1
1925
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
2687
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 time format ie he took the datatype of time now i want to generate a an excell sheet of that table but here i want the time to be like mm:ss but not hh:mm:ss examle the length of song sweet dreams is 01:12:35 now i want this to be shown as 72:35 how is there any procedure to convert directly in...
1
2169
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 time format ie he took the datatype of time now i want to generate a an excell sheet of that table but here i want the time to be like mm:ss but not hh:mm:ss examle the length of song sweet dreams is 01:12:35 now i want this to be shown as 72:35 how is there any procedure to convert directly in...
1
1755
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 field. I know I can use division and mod's to get the individual pieces but when I do: SELECT RaceTime / 3600 AS Hour FROM Race I get 1.233??? How do I just get the whole number without all of the decimals? Do you have any other suggestions on how to gets seconds into hh:mm:ss...
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10330
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10153
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10093
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7500
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2880
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.