Hello -
I have about ten integer values that each need to be converted to days,
hours, minutes and seconds. I can't seem to find a formula for same that
works. These integer values come from a Sql Server database that SUMS up the
seconds. The only way SUM will work in SS is with an integer value,
therefore, I could not use datetime in Sql Server.)
I need to ultimately put the converted values into ten datetimepicker
controls.
Does anyone have code for doing this? Any help will be appreciated!
--
Sheldon 5 12783
On Jul 5, 3:37*pm, Sheldon <Shel...@discussions.microsoft.comwrote:
Hello -
I have about ten integer values that each need to be converted to days,
hours, minutes and seconds. *I can't seem to find a formula for same that
works. *These integer values come from a Sql Server database that SUMS up the
seconds. *The only way SUM will work in SS is with an integer value,
therefore, I could not use datetime in Sql Server.)
I need to ultimately put the converted values into ten datetimepicker
controls.
Does anyone have code for doing this? *Any help will be appreciated!
--
Sheldon
Sounds like a good job for some simple looping and straight division.
You should be able to figure it out once you start playing with some
code.
Thanks,
Seth Rowe [MVP] http://sethrowe.blogspot.com/
"Sheldon" <Sh*****@discussions.microsoft.comkirjoitti viestissä
news:5B**********************************@microsof t.com...
Hello -
I have about ten integer values that each need to be converted to days,
hours, minutes and seconds. I can't seem to find a formula for same that
works. These integer values come from a Sql Server database that SUMS up
the
seconds. The only way SUM will work in SS is with an integer value,
therefore, I could not use datetime in Sql Server.)
I need to ultimately put the converted values into ten datetimepicker
controls.
Does anyone have code for doing this? Any help will be appreciated!
There are many ways to do this, but can you find this example useful:
Dim Seconds As Integer = 500
Dim Example1 As New TimeSpan(0, 0, Seconds)
Dim Example2 As DateTime
Example2 = Example2.AddSeconds(Seconds)
MsgBox(Seconds & " seconds is " & Example1.TotalHours & " hours")
MsgBox(Seconds & " seconds is " & Example2.Minute & " minutes and "
_
& Example2.Second & " seconds")
-Teemu
"Sheldon" <Sh*****@discussions.microsoft.comwrote in message
news:5B**********************************@microsof t.com...
Hello -
I have about ten integer values that each need to be converted to days,
hours, minutes and seconds. I can't seem to find a formula for same that
works. These integer values come from a Sql Server database that SUMS up
the
seconds. The only way SUM will work in SS is with an integer value,
therefore, I could not use datetime in Sql Server.)
I need to ultimately put the converted values into ten datetimepicker
controls.
Does anyone have code for doing this? Any help will be appreciated!
--
Sheldon
'The number of seconds in a day is (24 * 60 * 60 )
'Assuming TotalSeconds is your variable
'use integer division
Dim Daycount as Integer = TotalSeconds \ (24 * 60 * 60)
Dim SecondsRemaining as Integer = TotalSeconds - (DayCount * (24 * 60 *
60) )
Dim HourCount as Integer = SecondsRemaining \ (60 * 60)
SecondsRemaining = SecondsRemaining Mod (60 * 60)
Dim MinutesCount as Integer = SecondsRemaining \ 60
Dim SecondsCount as Integer = SecondsRemaining Mod 60
Sheldon wrote:
Hello -
I have about ten integer values that each need to be converted to days,
hours, minutes and seconds. I can't seem to find a formula for same that
works. These integer values come from a Sql Server database that SUMS up the
seconds. The only way SUM will work in SS is with an integer value,
therefore, I could not use datetime in Sql Server.)
I need to ultimately put the converted values into ten datetimepicker
controls.
Does anyone have code for doing this? Any help will be appreciated!
The most straight forward method is to simply turn the seconds into a
TimeSpan value:
t AS TimeSpan = TimeSpan.FromSeconds(seconds)
If you need a DateTime value, you have to pick a date that you start
counting from (i.e. the date that a zero seconds value would represent).
Then you just add the seconds to that.
d As DateTime = new DateTime(2008,1,1).AddSeconds(seconds)
--
Göran Andersson
_____ http://www.guffa.com
"Sheldon" <Sh*****@discussions.microsoft.comschrieb
Hello -
I have about ten integer values that each need to be converted to
days, hours, minutes and seconds. I can't seem to find a formula
for same that works. These integer values come from a Sql Server
database that SUMS up the seconds. The only way SUM will work in SS
is with an integer value, therefore, I could not use datetime in Sql
Server.)
I need to ultimately put the converted values into ten
datetimepicker controls.
Does anyone have code for doing this? Any help will be appreciated!
Use the TimeSpan structure, for example
Dim ts = TimeSpan.FromSeconds(1234)
Then you can access it's members, ts.days, ts.hours etc.
Armin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: NotGiven |
last post by:
Below is a good elapsed time function I found. However, I'd like to return
total seconds instead of broken down into days, hours, minutes & seconds.
In other words, I want "125" instead of "2...
|
by: Rudi Groenewald |
last post by:
Hi all.
If I've got a query which has a field with seconds in it... how will I use
the Convert function to get my field converted to the format: HH:MM:SS ?
The field with the seconds in is...
|
by: tdi1686 |
last post by:
I want to make a table that lists the Seconds / Hours / Days since the user
last visited my site, just like the myPHPnuke systems have, but I dont know
the best way to go about it.
At the moment...
|
by: 00_CP_D12 |
last post by:
Is there an easy way in ASP.NET to convert seconds to Hours: Minutes:
Seconds?
For example, 65 seconds will return 0 hr, 1 min, 5 secs.
Thanks...
|
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
| |
by: Jan |
last post by:
Hi:
I have an Access database that's been running (in one form or another)
for a couple of different clients for a few years. Now a new client has
requested that it be implemented with a SQL...
|
by: Carl J. Van Arsdall |
last post by:
Basically I used the datetime module and timedelta objects to calculate
a difference between two times. Now I'm trying to figure out how I make
that time delta a string HH:MM:SS to show elapsed...
|
by: WorldIsEnding |
last post by:
Hey,
Im having trouble with converting a Numeric value (such as a single
digit number like 1 or 5) into a time format.
I need to convert a number entered into a variable into Hours on the...
|
by: =?Utf-8?B?U2hlbGRvbg==?= |
last post by:
Hello -
I have various times formatted like 00:00:00, so for example, 01:32:05 would
be one thirty-two with five milliseconds.
I need to convert this into seconds (an integer).
First of...
|
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,...
|
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,...
| |
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| | |