Ciao a tutti.
Sul mio sito faccio visualizzare delle informazioni in maniera random. Alcune di queste informazioni non dovrebbero però essere più vecchie di 6 mesi.
posto il codice
codice:
<%

'gestione data per non andare oltre i 6 mesi
if Month(Date) = 1 then mese = "07" end if
if Month(Date) = 2 then mese = "08" end if
if Month(Date) = 3 then mese = "09" end if
if Month(Date) = 4 then mese = "10" end if
if Month(Date) = 5 then mese = "11" end if
if Month(Date) = 6 then mese = "12" end if
if Month(Date) = 7 then mese = "01" end if
if Month(Date) = 8 then mese = "02" end if
if Month(Date) = 9 then mese = "03" end if
if Month(Date) = 10 then mese = "04" end if
if Month(Date) = 11 then mese = "05" end if
if Month(Date) = 12 then mese = "06" end if

If Month(Date) < 6 then
anno = Year(Date) - 1
else
anno = Year(Date)
end if

giorno = Day(Date)
if Len(giorno) < 2 then
giorno = "0" & giorno
end if 

seimesifa= giorno & "/" & mese & "/" & anno

'estrazione di record casuali
Conn.Open strConn
Set rsreviews = Server.CreateObject("ADODB.Recordset")
query = "SELECT * FROM tbl_sostanze WHERE [data] >= # " & seimesifa & " #"

rsreviews.Open query,Conn,3,3
if not rsreviews.EOF then
  N = 1 'numero di record casuali da visualizzare
  Randomize
  max = rsreviews.RecordCount-1
  redim arr(max)
  'popolo l'array da 0 al numero di record 
  for i=0 to max
	arr(i)=i
  next
  'mischio i numeri in modo casuale
  for i=0 to max
    casuale = Int((max)*Rnd)
	temp = arr(i)
	arr(i) = arr(casuale)
	arr(casuale) = temp
  next
  'visualizzo gli N record casuali
  for i=0 to N-1
    rsreviews.Move arr(i)
%>
<table width="130" border="0" align="center" cellpadding="0" cellspacing="0" >
          <tr>
            <td align="center" height="2"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#39563e"></font><%response.write (rsreviews("data") & " " & seimesifa)%></td>
          </tr>
          <tr>
            <td width="130" height="130" align="center" valign="middle" background="../image/barre/cornice_02.gif" >
              
">[img]<%= rsreviews([/img]" width="100" border="0" align="absmiddle" />
</td>
          </tr>
</table>

    <%
    rsreviews.MoveFirst 
  next
end if
rsreviews.Close
set rsreviews = Nothing
conn.Close
set conn = Nothing
%>
Il codice per la randomizzazione non è mio, ma l'ho trovato sul web.
Il punto è che non funziona il limite della data, nonostante sia sintatticamente corretta

per esempio
data a caso nel db = 01/01/2008
seimesifa = 03/08/2007

e la query stampata a video
SELECT * FROM tbl_sostanze WHERE [data] >= # 03/08/2007 #

nonostante credo sia corretto mi mostra anche quelli più vecchi. Sapreste spiegarmi il motivo? C'entra in qualke modo la funzione random ( anche se non credo! )

Grazie in anticipo