This topic is locked

Elapsed Times

2/16/2007 11:27:27 AM
ASPRunnerPro General questions
G
grinningdog author

I've got some fields (Access DB) that are currently basic text fields in the DB but ASPRunner is formatting them as Time fields. Therefore I can enter 00.10.30 and it shows 00:10:30
What I want to do is to enter an elapsed time here and then deduct one time from the other as a result in a but I'm not sure if I can do this using a time field.
Specifically it's for a race, therefore I've got a start time and a finish time with 4 other times in between. All the timekeepers start their stopwatches at the same time and when the first times come in it will be in the format: Competitor No. 153 = 00.15.03 (i.e 15 minutes 3 seconds from the moment we all started our watches) Later I'll get 153 again 00.23.33 so I'll know that the first section took him 8 minutes 30 seconds.
I'll be creating new table views to enter this data and view it but I want to understand first if it's possible. I've read in this forum about problems with time formats in previous versions. For example, would I need to convert 00:15:03 into a number of seconds (903), deduct that from 00:23:33 (1413) and then display the result as seconds divided into hh:mm:ss i.e. 00:08:30
Two issues potentially: times could go up to say 6 hours (06:01:30) and the results could include totals of up to 4 or 5 hours (04:12:00)
Bob

Build 225

C
clig 2/17/2007

I've got some fields (Access DB) that are currently basic text fields in the DB but ASPRunner is formatting them as Time fields. Therefore I can enter 00.10.30 and it shows 00:10:30

What I want to do is to enter an elapsed time here and then deduct one time from the other as a result in a but I'm not sure if I can do this using a time field.
Specifically it's for a race, therefore I've got a start time and a finish time with 4 other times in between. All the timekeepers start their stopwatches at the same time and when the first times come in it will be in the format: Competitor No. 153 = 00.15.03 (i.e 15 minutes 3 seconds from the moment we all started our watches) Later I'll get 153 again 00.23.33 so I'll know that the first section took him 8 minutes 30 seconds.
I'll be creating new table views to enter this data and view it but I want to understand first if it's possible. I've read in this forum about problems with time formats in previous versions. For example, would I need to convert 00:15:03 into a number of seconds (903), deduct that from 00:23:33 (1413) and then display the result as seconds divided into hh:mm:ss i.e. 00:08:30
Two issues potentially: times could go up to say 6 hours (06:01:30) and the results could include totals of up to 4 or 5 hours (04:12:00)
Bob

Build 225


intT1 = dict("Time1")

intT2 = dict("Time2")
intHr1 = Cint(MID(intT1,1,2))

intMin1 = Cint(MID(intT1,4,2))

intSec1 = Cint(MID(intT1,7,2))

intHr2 = Cint(MID(intT2,1,2))

intMin2 = Cint(MID(intT2,4,2))

intSec2 = Cint(MID(intT2,7,2))
intTime = (intHr2 - intHr1) & "." & (intMin2 - intMin1) & "." & (intSec2 - intSec1)
Session("intTotal") = intTime
Response.Write "Calculation: " & Session("intTotal")
Calculation: 0.8.30

C
clig 2/24/2007



intT1 = dict("Time1")

intT2 = dict("Time2")
intHr1 = Cint(MID(intT1,1,2))

intMin1 = Cint(MID(intT1,4,2))

intSec1 = Cint(MID(intT1,7,2))

intHr2 = Cint(MID(intT2,1,2))

intMin2 = Cint(MID(intT2,4,2))

intSec2 = Cint(MID(intT2,7,2))
intTime = (intHr2 - intHr1) & "." & (intMin2 - intMin1) & "." & (intSec2 - intSec1)
Session("intTotal") = intTime
Response.Write "Calculation: " & Session("intTotal")
Calculation: 0.8.30


Sample:

*

Table columns:
id int 4 0

Start nvarchar 50 1

Finish nvarchar 50 1

Total nvarchar 50 1
***

Before Add:
Function BeforeAdd(dict)
' Parameters:

' dict - Scripting.Dictionary object.

' Each field on the Add form represented as 'Field name'-'Field value' pair
'** Custom code ****

' put your custom code here

intT1 = dict("Start")

intT2 = dict("Finish")

intHr1 = Cint(MID(intT1,1,2))

intMin1 = Cint(MID(intT1,4,2))

intSec1 = Cint(MID(intT1,7,2))

intHr2 = Cint(MID(intT2,1,2))

intMin2 = Cint(MID(intT2,4,2))

intSec2 = Cint(MID(intT2,7,2))

intTime = (intHr2 - intHr1) & "." & (intMin2 - intMin1) & "." & (intSec2 - intSec1)

dict("Total") = Replace(intTime, "-","")

BeforeAdd = True
' set BeforeAdd to True if you like to proceed with adding new record

' set it to False in other case
End Function
**
Before Edit
Function BeforeEdit(dict, where)
' Parameters:

' dict - Scripting.Dictionary object.

' Each field on the Edit form represented as 'Field name'-'Field value' pair

' where - string with WHERE clause pointing to record to be edited
'** Custom code ****

' put your custom code here

intT1 = dict("Start")

intT2 = dict("Finish")

intHr1 = Cint(MID(intT1,1,2))

intMin1 = Cint(MID(intT1,4,2))

intSec1 = Cint(MID(intT1,7,2))

intHr2 = Cint(MID(intT2,1,2))

intMin2 = Cint(MID(intT2,4,2))

intSec2 = Cint(MID(intT2,7,2))

intTime = (intHr2 - intHr1) & "." & (intMin2 - intMin1) & "." & (intSec2 - intSec1)

dict("Total") = Replace(intTime, "-","")
BeforeEdit = True
' set BeforeEdit to True if you like to proceed with editing this record

' set it to False in other case
End Function
****
The "Replace" strips "-"
***
Two table entry samples
00.10.30 00.15.03 0.5.27
00.10.35 00.23.44 0.13.9


G
grinningdog author 2/25/2007

Thanks very much. I'll get back on the case!! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=15801&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' />

Bob