473,804 Members | 2,191 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Converting HH:mm:ss to seconds

547 Contributor
I have a timing program. My next challenge is to convert hh:mm:ss into seconds. A user of my program wants to calculate watts for a hill climb race.
the formula i am going to use is:

Expand|Select|Wrap|Line Numbers
  1. =athlete weight (kg) x 9.8 x elevation gain (meters) / time (seconds)
i have everything except the seconds. We use a special Garmin gps to calculate the elevation gain in meter and i get the weight of the athlete using a scale on the day of the race.
I get the results from my timing program in hh.mm.ss format.The field to convert to seconds is called "Racingtime "
I attach the file to show the time (hh:mm:ss in the query
Please help
Attached Files
File Type: zip TimeToSeconds.zip (82.4 KB, 306 views)
Mar 20 '11 #1
2 12086
neelsfer
547 Contributor
I think it got it right. Converted it to minutes and then multiplied by 60 using this code in query
Expand|Select|Wrap|Line Numbers
  1. Timeseconds: TimeValue([RacingTime])*1440*60
Mar 20 '11 #2
NeoPa
32,579 Recognized Expert Moderator MVP
Your question isn't very clear as to whether you have a string in "hh:mm:ss" format or a DateTime value in days. As attachments should only ever be supplied as extra clarification for a question (and should never be considered as being part of it - especially not instead of explaining the question properly), and because both answers may prove helpful generally, I will answer both. Please bear this in mind for future questions though ;-)
  1. For a string "hh:mm:ss"
    This is best done with a public function in a standard module. Some of the tools to make this easier are not available for direct use in SQL.

    Expand|Select|Wrap|Line Numbers
    1. Public Function HMStoSec(strHMS As String) As Long
    2.     HMStoSec = Split(strHMS, ":")(0) * 3600 + _
    3.                Split(strHMS, ":")(1) * 60 + _
    4.                Split(strHMS, ":")(2)
    5. End Function
  2. For a DateTime value
    Essentially, your solution for a DateTime value would work. As there is no need to convert a time value using TimeValue() though, I would simplify it to :
    Expand|Select|Wrap|Line Numbers
    1. TimeSeconds: [RacingTime]*86400
Mar 20 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
17659
by: hikums | last post by:
Does anyone have a function to convert duration in seconds to a format hh:mm:ss Thanks.
2
2489
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
6
3108
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
4
39066
by: Rich | last post by:
Now.ToShortTimeString returns 9:13 PM. I would like to get this in miliatry time with seconds included 21:13:45 (or something like that - just military time with seconds). How can this be done? Thanks, Rich
14
4102
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
10613
by: kpp9c | last post by:
Hi, I was looking at python & datetime and hoping that it would already have a method/func to translate time formats. I need to translate seconds to hh:mm:ss.ms and vice versa and would like the ability to do some basic arithmetic in these formats. I think that there just has to be a package or module out there that already does this with reasonable speed and accuracy.
15
6637
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
1928
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
1756
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...
11
7463
by: neelsfer | last post by:
how add (longtime) totaltime = + in query; i need to be able to add more than 24hrs also but it can still show in this format ie (hh:mm:ss) 31:10:20 = 31hrs 10min 20sec pls help
0
9715
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
10603
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...
1
10356
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
10099
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
9176
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...
0
6869
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
4314
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
3836
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3003
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.