between finder kun yderpunkter
Hey Ejeg har en søgefunction til en db der kun finder start datoen og slutdatoen i db'en.
select koden ser således ud:
.................
<table>
<tr>
<td>søg fra dato<br>
<select name="fdatod">
<option value="">dag</option>
<% for i = 1 to 31 %>
<option value="<%=(i)%>"><%=(i)%></option>
<% next %>
</select>
<select name="fdatom">
<option value="">md</option>
<% for i = 1 to 12 %>
<option value="<%=(i)%>"><%=(i)%></option>
<% next %>
</select>
<select name="fdatoa">
<option value="">år</option>
<% for i = 2007 to 2014 %>
<option value="<%=(i)%>"><%=(i)%></option>
<% next %>
</select>
</td>
<td>søg til dato<br>
<select name="tdatod">
<option value="">dag</option>
<% for i = 1 to 31 %>
<option value="<%=(i)%>"><%=(i)%></option>
<% next %>
</select>
<select name="tdatom">
<option value="">md</option>
<% for i = 1 to 12 %>
<option value="<%=(i)%>"><%=(i)%></option>
<% next %>
</select>
<select name="tdatoa">
<option value="">år</option>
<% for i = 2007 to 2014 %>
<option value="<%=(i)%>"><%=(i)%></option>
<% next %>
</select>
</td>
</tr>
</table>
.................
så sendes form med POST til koden her der udtrækker resultatet:
.................
Dim fd, fm, fa, td, tm, ta, fra, til
for each x in request.Form
if left(x,6) = "S_Log_" AND request.Form(x) <> "" then
strSQL = strSQL & "(((EH101_status_log."&x & ")='" & request.Form(x) & "'))" & ";"
elseif mid(x,2,4) = "dato" then
if x = "fdatod" AND request.Form(x) <> "" then fd = request.Form(x) &"-"
if x = "fdatom" AND request.Form(x) <> "" then fm = request.Form(x) &"-"
if x = "fdatoa" AND request.Form(x) <> "" then fa = request.Form(x)
if Len(fd) = 2 then fd = "0" & fd
if Len(fm) = 2 then fm = "0" & fm
if x = "tdatod" AND request.Form(x) <> "" then td = request.Form(x) &"-"
if x = "tdatom" AND request.Form(x) <> "" then tm = request.Form(x) &"-"
if x = "tdatoa" AND request.Form(x) <> "" then ta = request.Form(x)
if Len(td) = 2 then td = "0" & td
if Len(tm) = 2 then tm = "0" & tm
end if
next
fra = fd&fm&fa
til = td&tm&ta
if len(fra) > 0 AND len(til) = 0 then
strSQL = strSQL & "(((EH101_status_log.S_Log_date) LIKE'%" & fra & "%'))" & ";"
elseif len(til) > 0 AND len(fra) = 0 then
strSQL = strSQL & "(((EH101_status_log.S_Log_date) LIKE'%" & til & "%'))" & ";"
elseif len(fra) > 0 AND len(til) > 0 then
strSQL = strSQL & "(((EH101_status_log.S_Log_date) BETWEEN '" & fra & "' AND '" & til & "'))" & ";"
else
strSQL = strSQL
end if
tal = Len(strSQL) -1
strSQL = left(strSQL,tal)
strSQL = replace(strSQL,";"," AND ")
strSQL = "SELECT * FROM EH101_status_log WHERE " & strSQL & " ORDER BY Status_Log_ID DESC"
rs_custom strSQL,3,"log"
if rs.EOF or rs.BOF then
response.Redirect("default.asp?mode=historik_seek&resultat=no")
else
arrMitArray = rs.GetRows
end if
rs_end()
...................
hvis jeg har søgt fra 23-02-2007 til 03-03-2007 er resultatet
...................
| 1.col | 2.col |
-----------------------------
1.rk|23-02-2007 | fisk |
-----------------------------
2.rk|23-02-2007 | fisk |
-----------------------------
3.rk|03-03-2007 | hest |
-----------------------------
4.rk|03-03-2007 | mus |
-----------------------------
.....................
jeg mangler at få vist data fra den
24-02-2007
25-02..
26
27
28
01-03-2007
02-03..
.............
Kan i hjælpe?
