473,881 Members | 1,679 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 3109
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
17677
by: hikums | last post by:
Does anyone have a function to convert duration in seconds to a format hh:mm:ss Thanks.
2
2492
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
4107
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
2768
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
6642
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
1930
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
2695
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
2171
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
1760
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
9776
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10724
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
10827
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,...
0
10403
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9556
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7954
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
7113
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();...
1
4599
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
2
4198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.