454,226 Members | 1,435 Online
Need help? Post your question and get tips & solutions from a community of 454,226 IT Pros & Developers. It's quick & easy.

# Race Hours

 P: n/a 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 Replies

 P: n/a 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" 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

 P: n/a 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

 P: n/a "Rebecca Smith" 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

 P: n/a 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

 P: n/a 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 discussion thread is closed

Replies have been disabled for this discussion.