Calculate the difference between entries in recordset..

  • Thread starter Kenneth Johansen
  • Start date
K

Kenneth Johansen

Hi NG,

How do i calculate the difference in a recordset ?

Here's what i have now...

A large SQL query with a lot of joins and this : (the tables i use have a
lot of data)

<%
DO WHILE NOT rs.EOF OR rs.BOF

Response.write "<tr>"
Response.write "<td width=""167"">" & rs("WXS001") & "&nbsp;</span></td>"
Response.write "<td width=""234"">" & rs("WXS004") & "&nbsp;</span></td>"
Response.write "<td width=""100"">" & rs("XJS004") & "&nbsp;</span></td>"
Response.write "<td width=""167"">" & rs("XJS005") & "&nbsp;</span></td>"
Response.write "<td width=""167"">" & rs("XHS003") & "&nbsp;</span></td>"
Response.write "</tr>"

rs.MoveNext
LOOP
Else
rs.Close
Response.write "</table>"
myConn.Close
set myConn=nothing
end if
%>

I want to find the difference between 0 and rs("XJS005") and then the first
rs("XJS005") and the second, then between the second and the third.. To have
the interval between them...

I hope you understand my point, how do i accomplish this.

Regards
Kenneth Johansen
 
K

Ken Schaefer

<%
Dim lngTemp ' as long
Dim lngDifference ' as long
lngTemp = 0
Do While Not objRS.EOF

lngDifference = rs("XJS005") - lngTemp
Response.Write(lngDifference)
lngTemp = rs("XJS005")

' Do existing stuff

objRS.MoveNext

Loop
%>


: Hi NG,
:
: How do i calculate the difference in a recordset ?
:
: Here's what i have now...
:
: A large SQL query with a lot of joins and this : (the tables i use have a
: lot of data)
:
: <%
: DO WHILE NOT rs.EOF OR rs.BOF
:
: Response.write "<tr>"
: Response.write "<td width=""167"">" & rs("WXS001") &
"&nbsp;</span></td>"
: Response.write "<td width=""234"">" & rs("WXS004") &
"&nbsp;</span></td>"
: Response.write "<td width=""100"">" & rs("XJS004") &
"&nbsp;</span></td>"
: Response.write "<td width=""167"">" & rs("XJS005") &
"&nbsp;</span></td>"
: Response.write "<td width=""167"">" & rs("XHS003") &
"&nbsp;</span></td>"
: Response.write "</tr>"
:
: rs.MoveNext
: LOOP
: Else
: rs.Close
: Response.write "</table>"
: myConn.Close
: set myConn=nothing
: end if
: %>
:
: I want to find the difference between 0 and rs("XJS005") and then the
first
: rs("XJS005") and the second, then between the second and the third.. To
have
: the interval between them...
:
: I hope you understand my point, how do i accomplish this.
:
: Regards
: Kenneth Johansen
:
:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top