stevem2004
12-21-2004, 04:20 AM
Hi, I have the following data from a access db
ID Date User System Time Taken
4 14/12/04 esol Internet 5
6 15/12/04 EsOL Internet 2250
8 15/12/04 dkfha Testing 50
9 15/12/04 Villy Internet 1350
10 16/12/04 Webcom Internet 900
11 20/12/04 Me Misc 15
12 20/12/04 Task Duty Jobs 180
13 20/12/04 Gavin Misc 210
which is retrieved by the following code:
<table width="700" cellpadding="2" cellspacing="0" border="1" bordercolor="#809CC9">
<tr>
<th class="normal">ID</th>
<th class="normal">Date</th>
<th class="normal">User</th>
<th class="normal">Created by</th>
<th class="normal">System</th>
<th class="normal">Query</th>
<th class="normal">Time Taken</th>
</tr>
<%
dim conn, rs, strconn, strSQL, strDate
strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("../database/database.mdb")
set conn = server.createobject("adodb.connection")
conn.open strconn
strSQL = "SELECT * FROM table WHERE status = 'Closed';"
set rs = server.createobject("adodb.recordset")
rs.open strSQL, conn, 3, 3
Dim i, count
Dim arrIDs()
Dim dte
count = 0
rs.MoveFirst
For i = 0 To rs.RecordCount
If Not rs.EOF Then
dte = DateValue(rs("date"))
Dim intDiff
intDiff = DateDiff("d", dte, DateAdd("d", -1, Date()))
If intDiff >= 0 And intDiff <= 30 Then
ReDim Preserve arrIDs(count)
arrIDs(count) = rs("id")
count = count + 1
End If
rs.MoveNext
End If
Next
%>
<p class="normal">
<%
For i = 0 To UBound(arrIDs)
' Response.Write (arrIDs(i) & ", ")
Next
%>
<%
strQuery = "SELECT * FROM table WHERE "
For i = 0 To UBound(arrIDs)
If i > 0 Then
strQuery = strQuery & " OR id = " & arrIDs(i)
Else
strQuery = strQuery & "id = " & arrIDs(i)
End If
Next
Set conn = Server.CreateObject("ADODB.Connection")
strConn = "DBQ=" & Server.MapPath("../database/data.mdb") & ";" & _
"Driver={Microsoft Access Driver (*.mdb)}"
conn.Open(strConn)
Set RS = Server.CreateObject("ADODB.RecordSet")
RS.Open(strQuery), conn, 3
If RS.EOF and RS.BOF Then
Response.Write ("No Logs Last week")
Response.End
End If
RS.MoveFirst
For i = 0 To RS.RecordCount
If Not RS.EOF Then
Response.Write ("<tr><td class=""normal""><a href=""../view/view.asp?id=" & rs("id") & """>" & rs("id") & "</a>" & "</td><td class=""normal"">" & rs("date") & "</td><td class=""normal"">" & rs("user") & "</td><td class=""normal"">" & rs("rscmember") & "</td><td class=""normal"">" & rs("system") & "</td><td class=""normal"">" & rs("query") & "</td><td class=""normal"">" & rs("timetaken") & "</td></tr>")
RS.MoveNext
End If
Next
%>
</table>
What I would like to do, but can't think how, is to add the time taken field up (which is in minutes), as you can see this code retrieves the last week's worth of data, does anybody know how I can add these values, within this query?
Many Thanks
Steve
ID Date User System Time Taken
4 14/12/04 esol Internet 5
6 15/12/04 EsOL Internet 2250
8 15/12/04 dkfha Testing 50
9 15/12/04 Villy Internet 1350
10 16/12/04 Webcom Internet 900
11 20/12/04 Me Misc 15
12 20/12/04 Task Duty Jobs 180
13 20/12/04 Gavin Misc 210
which is retrieved by the following code:
<table width="700" cellpadding="2" cellspacing="0" border="1" bordercolor="#809CC9">
<tr>
<th class="normal">ID</th>
<th class="normal">Date</th>
<th class="normal">User</th>
<th class="normal">Created by</th>
<th class="normal">System</th>
<th class="normal">Query</th>
<th class="normal">Time Taken</th>
</tr>
<%
dim conn, rs, strconn, strSQL, strDate
strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("../database/database.mdb")
set conn = server.createobject("adodb.connection")
conn.open strconn
strSQL = "SELECT * FROM table WHERE status = 'Closed';"
set rs = server.createobject("adodb.recordset")
rs.open strSQL, conn, 3, 3
Dim i, count
Dim arrIDs()
Dim dte
count = 0
rs.MoveFirst
For i = 0 To rs.RecordCount
If Not rs.EOF Then
dte = DateValue(rs("date"))
Dim intDiff
intDiff = DateDiff("d", dte, DateAdd("d", -1, Date()))
If intDiff >= 0 And intDiff <= 30 Then
ReDim Preserve arrIDs(count)
arrIDs(count) = rs("id")
count = count + 1
End If
rs.MoveNext
End If
Next
%>
<p class="normal">
<%
For i = 0 To UBound(arrIDs)
' Response.Write (arrIDs(i) & ", ")
Next
%>
<%
strQuery = "SELECT * FROM table WHERE "
For i = 0 To UBound(arrIDs)
If i > 0 Then
strQuery = strQuery & " OR id = " & arrIDs(i)
Else
strQuery = strQuery & "id = " & arrIDs(i)
End If
Next
Set conn = Server.CreateObject("ADODB.Connection")
strConn = "DBQ=" & Server.MapPath("../database/data.mdb") & ";" & _
"Driver={Microsoft Access Driver (*.mdb)}"
conn.Open(strConn)
Set RS = Server.CreateObject("ADODB.RecordSet")
RS.Open(strQuery), conn, 3
If RS.EOF and RS.BOF Then
Response.Write ("No Logs Last week")
Response.End
End If
RS.MoveFirst
For i = 0 To RS.RecordCount
If Not RS.EOF Then
Response.Write ("<tr><td class=""normal""><a href=""../view/view.asp?id=" & rs("id") & """>" & rs("id") & "</a>" & "</td><td class=""normal"">" & rs("date") & "</td><td class=""normal"">" & rs("user") & "</td><td class=""normal"">" & rs("rscmember") & "</td><td class=""normal"">" & rs("system") & "</td><td class=""normal"">" & rs("query") & "</td><td class=""normal"">" & rs("timetaken") & "</td></tr>")
RS.MoveNext
End If
Next
%>
</table>
What I would like to do, but can't think how, is to add the time taken field up (which is in minutes), as you can see this code retrieves the last week's worth of data, does anybody know how I can add these values, within this query?
Many Thanks
Steve