Hjælp
HejJeg har et script, som skal finde datoer, som forekommer 2 gange eller derover. I mængden af datoer i min db, er der dog kun en dato, som forekommer 2 gange, og det er datoen "03-05-2003".
Men selv se på følgende side - det virker slet ikke:
http://www.selvet.dk/exp.asp
<%
Set myConn=Server.CreateObject("ADODB.Connection")
myConn.Open ("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE="+server.Mappath("/db/selvet.mdb"))
strSQL = "SELECT datopublish FROM search WHERE datopublish >= #" & Year(date) & "-" & month(date) & "-" & Day(date) & "# AND datopublish < #" & Year(dateadd("yyyy",1,date)) & "-" & month(dateadd("yyyy",1,date)) & "-" & Day(dateadd("yyyy",1,date)) & "# order by datopublish"
set rs = myConn.execute(strSQL)
response.write "<br>strSQL: " & strSQL & "<br><br>"
do while not rs.EOF
if isDate(rs("datopublish")) then
myDates = myDates & rs("datopublish") & ", "
End If
rs.MoveNext
Loop
if right(myDates, 2) = ", " then
myDates = left(myDates,len(myDates)-2)
end if
response.write "<br>Skal undersøge: <br>" & myDates & "<br><br><br>"
response.write "<br>Finder: <br>"
myDateArr = Split(myDates,",")
dato = date ()
datoSlut = DateAdd("yyyy",1,date)
i = 0
do while dato <= datoSlut
if countDates(myDateArr(i), myDates) < 2 AND CDate(myDateArr(i)) <> CDate(dato) then
response.write myDateArr(i) & ", "
else
i = i + 1
if i > ubound(myDateArr) then i = ubound(myDateArr)
end if
dato = dateAdd("d",1,dato)
loop
response.write "<br><br>Det havde været rigtigt, hvis den havde skrevet alle datoerne, undtagen 03-05-2003<br>"
Function countDates(patrn, strng)
Dim regEx, Match, Matches ' Create variable.
Set regEx = New RegExp ' Create regular expression.
regEx.Pattern = patrn ' Set pattern.
regEx.IgnoreCase = True ' Set case insensitivity.
regEx.Global = True ' Set global applicability.
Set Matches = regEx.Execute(strng) ' Execute search.
For Each Match in Matches ' Iterate Matches collection.
intMatchCount = intMatchCount + 1
Next
countDates = intMatchCount
End Function
%>