473,503 Members | 1,654 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

convert seconds to HH:MM

I'm getting my data from my database in seconds, 3600, how can i convert that
to time such as 1:00 pm?
Nov 21 '05 #1
6 1532
Mike,

The one which a regular from this newsgroup consequently forget.

http://msdn.microsoft.com/library/de...condstopic.asp

I hope this helps?

Cor
Nov 21 '05 #2
I'll check that out, but i've seen it done in 2 lines of code as well and now
i can't find that snippet again.
thx

"Cor Ligthert" wrote:
Mike,

The one which a regular from this newsgroup consequently forget.

http://msdn.microsoft.com/library/de...condstopic.asp

I hope this helps?

Cor

Nov 21 '05 #3
Mike,
I'll check that out, but i've seen it done in 2 lines of code as well and
now
i can't find that snippet again.


In the sample in the link it is one line of code, however maybe can you as
in that break it up in two than it looks like two.

MessageBox.Show(TimeSpan.FromSeconds(3600).ToStrin g)

:-)

Cor
Nov 21 '05 #4
Mike,
I normally use TimeSpan.FromSeconds (as Cor suggested):

Dim ts As TimeSpan = TimeSpan.FromSeconds(3600)

If you want it as a "Date" I normally add the TimeSpan to a "known"
DateTime.

Dim dt As DateTime = DateTime.MinValue.Add(ts)

Alternatively you can add the seconds to a "known" DateTime.

Dim ts As DateTime = DateTime.MinValue.AddSeconds(3600)

Hope this helps
Jay

"Mike" <Mi**@discussions.microsoft.com> wrote in message
news:77**********************************@microsof t.com...
I'm getting my data from my database in seconds, 3600, how can i convert
that
to time such as 1:00 pm?

Nov 21 '05 #5
will these work with a dataitem from a dataset?
"Jay B. Harlow [MVP - Outlook]" wrote:
Mike,
I normally use TimeSpan.FromSeconds (as Cor suggested):

Dim ts As TimeSpan = TimeSpan.FromSeconds(3600)

If you want it as a "Date" I normally add the TimeSpan to a "known"
DateTime.

Dim dt As DateTime = DateTime.MinValue.Add(ts)

Alternatively you can add the seconds to a "known" DateTime.

Dim ts As DateTime = DateTime.MinValue.AddSeconds(3600)

Hope this helps
Jay

"Mike" <Mi**@discussions.microsoft.com> wrote in message
news:77**********************************@microsof t.com...
I'm getting my data from my database in seconds, 3600, how can i convert
that
to time such as 1:00 pm?


Nov 21 '05 #6
Mike,
Yes of course they do.

Obviously you may need to convert types to/from the parameters expected &
returned.
The DataSet supports TimeSpans, however I have not tried getting them into &
out of a database...
Hope this helps
Jay

"Mike" <Mi**@discussions.microsoft.com> wrote in message
news:88**********************************@microsof t.com...
will these work with a dataitem from a dataset?
"Jay B. Harlow [MVP - Outlook]" wrote:
Mike,
I normally use TimeSpan.FromSeconds (as Cor suggested):

Dim ts As TimeSpan = TimeSpan.FromSeconds(3600)

If you want it as a "Date" I normally add the TimeSpan to a "known"
DateTime.

Dim dt As DateTime = DateTime.MinValue.Add(ts)

Alternatively you can add the seconds to a "known" DateTime.

Dim ts As DateTime = DateTime.MinValue.AddSeconds(3600)

Hope this helps
Jay

"Mike" <Mi**@discussions.microsoft.com> wrote in message
news:77**********************************@microsof t.com...
> I'm getting my data from my database in seconds, 3600, how can i
> convert
> that
> to time such as 1:00 pm?
>
>


Nov 21 '05 #7

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

Similar topics

4
17574
by: hikums | last post by:
Does anyone have a function to convert duration in seconds to a format hh:mm:ss Thanks.
2
2476
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...
6
3090
by: Able | last post by:
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
2
6926
by: Robert Brown | last post by:
Hi all. I have written a program that transfers data via FTP. I can calculate the rough amount of time left. I get a value such as 70.83 seconds left for instance. What I want to do is to...
14
4064
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!
5
19163
nirmalsingh
by: nirmalsingh | last post by:
i am getting date format in string as 30-11-2006 05:59:44 PM . i want to convert in the format of yyyy-mm-dd hh:mm:ss to sore it in mysql database. Help me with sample coding plz..
1
2665
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...
1
2140
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...
1
1743
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...
5
32282
by: sudip77 | last post by:
Hi, I have an user input variable called @stop_time which takes input in the format of HH:MM:SS. I need to convert it into seconds only. How can I do that? Can anyone help please?
0
7198
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,...
0
7072
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...
0
7271
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,...
0
7319
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...
1
6979
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...
0
7449
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...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1498
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 ...

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.