nelslynn
09-30-2003, 01:01 AM
I am using an asp datalist to display the results of a query. This is accomplished in the Page_load Sub. There is one calulation that needs to be done before I display the results. I need to divide a hours and minutes field by a number (miles) to display pace Per Mile. For Example: (hh:mm)/2.25. How do I accomplish this?
The calculation subroutine is too complicated for the query... here's the calcultion as a VB function:
Public Function fPace(mi As Double, t As Date) As String
Dim tSec As Long
Dim hrs As Integer
Dim mins As Integer
Dim secs As Integer
Dim secMi As Integer
Dim temp As Date
Dim ret As String
tSec = (Hour(t) * 3600) + (Minute(t) * 60) + Second(t)
secMi = Int(tSec / mi)
hrs = Int(secMi / 3600)
mins = Int((secMi - (hrs * 3600)) / 60)
secs = secMi - ((hrs * 3600) + (mins * 60))
Select Case hrs
Case Is = 0
fPace = mins & ":" & Format(secs, "00")
'fPace = CInt(mins) & ":" & Format(CInt(secs), "00")
Case Else
fPace = hrs & ":" & Format(mins, "00") & ":" & Format(secs, "00")
End Select
End Function
I get the hh:mm (split1) from the query and display it like:
<TD class="text" width="30"><%# DataBinder.Eval(Container.DataItem, "split1") %></TD>
Thanks for any help
The calculation subroutine is too complicated for the query... here's the calcultion as a VB function:
Public Function fPace(mi As Double, t As Date) As String
Dim tSec As Long
Dim hrs As Integer
Dim mins As Integer
Dim secs As Integer
Dim secMi As Integer
Dim temp As Date
Dim ret As String
tSec = (Hour(t) * 3600) + (Minute(t) * 60) + Second(t)
secMi = Int(tSec / mi)
hrs = Int(secMi / 3600)
mins = Int((secMi - (hrs * 3600)) / 60)
secs = secMi - ((hrs * 3600) + (mins * 60))
Select Case hrs
Case Is = 0
fPace = mins & ":" & Format(secs, "00")
'fPace = CInt(mins) & ":" & Format(CInt(secs), "00")
Case Else
fPace = hrs & ":" & Format(mins, "00") & ":" & Format(secs, "00")
End Select
End Function
I get the hh:mm (split1) from the query and display it like:
<TD class="text" width="30"><%# DataBinder.Eval(Container.DataItem, "split1") %></TD>
Thanks for any help