Visualizzazione dei risultati da 1 a 2 su 2

Discussione: ORDER BY "Data"

  1. #1
    Utente di HTML.it
    Registrato dal
    May 2001
    Messaggi
    63

    ORDER BY "Data"

    Ciao Ragazzi,

    ho una pagina asp che fa una richiesta ad un DB e mi restituisce i dati dandomi la prossima data che arriverà in base alla data odierna e poi me li ordina in modo ASC.

    Ora la domandona è....perché mi ordina le date in modo sballato???

    Il link per vedere il listato è questo:

    http://212.147.30.69/corsi_all.asp

    Se osservate le date del 8.11.2010 e 9.11.2010 non sono al loro posto!

    Ecco il codice che ho usato nella pagina:

    <html>
    <head>
    <title>Cc-Ti >> archivio corsi</title>
    <LINK href="css/styles.css" type=text/css rel=stylesheet>
    </head>
    <META http-equiv=Content-Language content=it>
    <META http-equiv=content-type content="text/html; charset=ISO-8859-1">
    <body>
    <h1>[img]img/archivio_corsi.png[/img]</h1>
    <%
    Set Conn=Server.CreateObject("ADODB.Connection")
    strConn="driver={Microsoft Access Driver (*.mdb)}; "
    strConn=strConn & " DBQ=" & Server.MapPath("db/news.mdb")
    Conn.Open strConn
    oggi = year(date()) &"-"& right("0"& month(date()),2) &"-"& right("0"& day(date()),2)
    sql = "SELECT * FROM tbCorsi WHERE tbCorsi.Data >= '"& oggi &"' ORDER BY tbCorsi.Data ASC"
    Set rs = Server.CreateObject("ADODB.Recordset")
    Set rs.ActiveConnection = conn

    rs.Source = "tbCorsi"
    rs.Open sql, conn

    If rs.EOF Then
    %>



    Nessun record trovato!</p>
    <%
    Else
    While rs.EOF = False
    %>
    <%
    data = day(rs("Data")) &"."& month(rs("Data")) &"."& year(rs("Data"))
    %>


    <%=data%>
    <%=rs("Titolo")%>[b]
    <%=rs("Link")%></p>


    <%
    rs.MoveNext
    Wend
    End If
    rs.Close


    set rs = Nothing
    conn.Close
    set conn = Nothing
    %>
    </body>
    </html>

    Grazie mille!
    Olly

  2. #2
    perchè hai inserito le date come testo ed ovviamente il 3 è più piccolo dell'8 ovvero 30 viene prima di 8 =)
    prova ad aggiungere uno "0" davantio alla data e ad ordinare ASC prendendo solo le prime due lettere

    oggi="0"&oggi
    sql = "SELECT * FROM tbCorsi WHERE tbCorsi.Data >= '"& oggi &"' ORDER BY Left (tbCorsi.Data, 2) ASC"

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.