473,394 Members | 1,640 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Race Hours

I'm building log book to keep track of a racers stats during a long ultra
marathon race. Things such as time on the bike, time off, H20 intake,
electrolytes and the like.
When I say long I mean days! I'd like to have on the input form, the running
number of hours the race has been in progress. DateDiff only allows me "h"
or hours and this won't take me past 24. I've tried other combinations of
formats and formulas but am just spinning my wheels.
I'd sure appreciate some help on figuring out how many hours the race has
been in progress since the starting gun.
Thank you,
Becky

PS - Access 97
Nov 13 '05 #1
5 1731
I always try to change time and date values into numbers rather than
dates/times. It simply works a lot simpler. Then, in the end, you convert
them back to hours/days or what have you.

0 = 30-dec-1899, each day from then adds one.

24-May-04 = 38131

to work out the difference between, for example today and three days ago
date()-(date()-3)

to work out the difference between, for example, today and a specific date:

int(date() - #12-12-03#)

hours are fractions (e.g. .5 = mid day).

hope this helps

I really found the date and time functions did not do it for me and gave me
all sorts of roblems.

"Rebecca Smith" <rp*****@pcez.com> wrote in message
news:10*************@corp.supernews.com...
I'm building log book to keep track of a racers stats during a long ultra
marathon race. Things such as time on the bike, time off, H20 intake,
electrolytes and the like.
When I say long I mean days! I'd like to have on the input form, the running number of hours the race has been in progress. DateDiff only allows me "h"
or hours and this won't take me past 24. I've tried other combinations of
formats and formulas but am just spinning my wheels.
I'd sure appreciate some help on figuring out how many hours the race has
been in progress since the starting gun.
Thank you,
Becky

PS - Access 97

---
Please immediately let us know (by phone or return email) if (a) this email
contains a virus
(b) you are not the intended recipient
(c) you consider this email to be spam.
We have done our utmost to make sure that
none of the above are applicable. THANK YOU
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.690 / Virus Database: 451 - Release Date: 22/05/2004
Nov 13 '05 #2
WindAndWaves,
Thanks for the reply. Where the real problem seems to lie is when I try
format, let's say 49 hours. If I use Format(myTime, "h:m:s") only 1 hour
returns. If for instance I add in an extra 'h' all that does is to put a
zero in front of the 1. Any ideas?
Thanks,
B.
I always try to change time and date values into numbers rather than
dates/times. It simply works a lot simpler. Then, in the end, you convert them back to hours/days or what have you.

0 = 30-dec-1899, each day from then adds one.

24-May-04 = 38131

to work out the difference between, for example today and three days ago
date()-(date()-3)

to work out the difference between, for example, today and a specific date:
int(date() - #12-12-03#)

hours are fractions (e.g. .5 = mid day).

hope this helps

I really found the date and time functions did not do it for me and gave me all sorts of roblems.

Nov 13 '05 #3
"Rebecca Smith" <rp*****@pcez.com> wrote in
news:10*************@corp.supernews.com:
I'm building log book to keep track of a racers stats during a
long ultra marathon race. Things such as time on the bike,
time off, H20 intake, electrolytes and the like.
When I say long I mean days! I'd like to have on the input
form, the running number of hours the race has been in
progress. DateDiff only allows me "h" or hours and this won't
take me past 24. I've tried other combinations of formats and
formulas but am just spinning my wheels. I'd sure appreciate
some help on figuring out how many hours the race has been in
progress since the starting gun. Thank you,
Becky

PS - Access 97


the datediff() function will give you all you need.

store the starting datetime of the race, and calculate the
duration to now, I like to use seconds for my calcs
Dim ElapsedTime as double
ElapsedTime = Datediff("s",[race start],now())

To format it as hours and minutes, you need a custom format
routine. Put this in a module and call wherever needed.

public function sec2dur(duration as double) as string
dim hours as integer, mins as integer, secs as integer
hours = int(duration * 3600)
mins = int(duration*60) - hours*60
secs = duration - (hours*3600-mins*60)

sec2dur = format(hours,"000") & ":" & format(mins,"00") & ";" &
format(secs,"00")

end function

I store the start and end time for each lap in a table, and have
a query show the duration of each lap, I can get total times by
having the query select the ElapsedTime and summing that, and
formatting the result.

For your described use, just place the expression in a textbox on
the form, You will need to use the timer event to recalculate
every minute or so.
Bob Quintal
Nov 13 '05 #4
Bob got a good solution

here is my function for time:

Public Function HAS(DAT As Double) As String 'Dat is time in numbers (e.g.
1.5 = 36 hours)
'hours as string
'On Error GoTo err
Dim h As Long, m As Long, s As Long, Sec As Double
Sec = DAT
h = Int(Sec * 24)
m = Int(Sec * 1440) - (h * 60)
s = Round(Sec * 86400) - ((h * 3600) + (m * 60))
HAS = Format(h, "000") & ":" & Format(m, "00") & ":" & Format(s, "00")
xit:
Exit Function
err:
HAS = "00:00:00"
resume xit
End Function
---
Please immediately let us know (by phone or return email) if (a) this email
contains a virus
(b) you are not the intended recipient
(c) you consider this email to be spam.
We have done our utmost to make sure that
none of the above are applicable. THANK YOU
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.690 / Virus Database: 451 - Release Date: 22/05/2004
Nov 13 '05 #5
Bob,
Thanks and a hat tip! It took me more than a few moments to get everything
up and running but once I did it worked perfectly. The real modification I
did to your code was to eliminate seconds and add the days. Once I saw the
solution you presented it was fairly easy to progress as required.
Thanks a lot.
B.

PS - WindAndWaves - I'll look over your solution to see how it differs and
then play with it a bit. Thanks!

the datediff() function will give you all you need.

store the starting datetime of the race, and calculate the
duration to now, I like to use seconds for my calcs
Dim ElapsedTime as double
ElapsedTime = Datediff("s",[race start],now())

To format it as hours and minutes, you need a custom format
routine. Put this in a module and call wherever needed.

public function sec2dur(duration as double) as string
dim hours as integer, mins as integer, secs as integer
hours = int(duration * 3600)
mins = int(duration*60) - hours*60
secs = duration - (hours*3600-mins*60)

sec2dur = format(hours,"000") & ":" & format(mins,"00") & ";" &
format(secs,"00")

end function
Bob Quintal

Nov 13 '05 #6

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

Similar topics

5
by: GIMME | last post by:
One of my coworkers insists that one should never use static methods because race conditions exist. Thinking along the lines that all variable assignments are assignments to static variables. ...
3
by: dh | last post by:
Runtime.getRuntime().exec() ... mad buffering of stdout ... It buffers stdout without limit ... so if your Java program doesn't keep up with the Process output then memory fills up! I wish it...
1
by: Swami Tota Ram Shankar | last post by:
"Bob Weigel" <dontuwish@nothing.net> wrote in message > > While George Bush, is the epitome of evil, racism, and uncompassionate > > conservatism, Kerry is either deluded, very deluded, or...
18
by: Urs Vogel | last post by:
Hi I wrote an application server (a remoting sinlgeton), where processes must be stopped in very rare cases, done thru a Thread.Abort(). Occasionally, and only after a Thread.Abort(), this...
2
by: manuelg | last post by:
Here is a code fragment, where I am trying to copy a file, avoiding overwrites and race conditions. The filename gets a '02','03','04' etc appended to the end if a file with that name already...
2
by: aldaris | last post by:
"race N cars are lined up at the starting line of a Formula 1 race. Task Write a program that determines in how many ways the cars can pass the finish line, knowing that there may be more than one...
7
by: Berryl Hesh | last post by:
I wouldn't nomally post this here, as it has something to do with the ListView control usage I think, or maybe with a race condition or some windoes messaging. I'm just not sure. The test below...
0
by: moltendorf | last post by:
I've been trying to find a suitable method for preventing race conditions in my own code. Currently I'm using a file and the flock function to prevent code in other threads from executing at the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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...
0
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...

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.