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 12889
On Jul 5, 3:37*pm, Sheldon <Shel...@discus sions.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*****@discus sions.microsoft .comkirjoitti viestissä
news:5B******** *************** ***********@mic rosoft.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.AddSec onds(Seconds)
MsgBox(Seconds & " seconds is " & Example1.TotalH ours & " hours")
MsgBox(Seconds & " seconds is " & Example2.Minute & " minutes and "
_
& Example2.Second & " seconds")
-Teemu
"Sheldon" <Sh*****@discus sions.microsoft .comwrote in message
news:5B******** *************** ***********@mic rosoft.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 SecondsRemainin g as Integer = TotalSeconds - (DayCount * (24 * 60 *
60) )
Dim HourCount as Integer = SecondsRemainin g \ (60 * 60)
SecondsRemainin g = SecondsRemainin g Mod (60 * 60)
Dim MinutesCount as Integer = SecondsRemainin g \ 60
Dim SecondsCount as Integer = SecondsRemainin g 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.FromSe conds(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*****@discus sions.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.FromSe conds(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 minutes 5 seconds".
Any ideas? Thanks very much!
function calcElapsedTime($time)
{ // calculate elapsed time (in seconds!)
$diff = time()-$time;
|
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 called: "Diff"
Thanks alot
|
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 when the user calls the page the database is updated with the
current date/time for that user.
Should I do this in the VB code in the page or write a SQL statement to do
this?
|
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 server back-end. I'm doing
my best to learn about SQL server, and I plan to leave the front-end
more or less as-is, just linking to the SQL server back end, but here's
a basic question:
The db has a front-end linked to two back-ends. One of the...
|
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 time. I've spent tons
of time looking at the module's documentation but I'm not seeing how
those methods will help me. Can anyone help me with this?
Here's what I'm trying to do, assum that resultsDict is a dictionary of
objects that have...
|
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
first form, then from Hours into Seconds when a second form is loaded.
Anyone got any ideas? If you need more info, let me know and ill post
a code snippet or something.
|
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 all, I have been unable to use the mid() function like I did in vb
6.
|
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...
|
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,...
| |
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...
|
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...
|
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,...
|
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...
|
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();...
|
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
| |
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...
| | |