Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 18
  1. #1

    unire campi nella query e confrontarli

    Salve, vorrei unire i campi giorno mese anno del mio database mssql e poi ricercare gli ultimi 10 records della data compresa tra 01/05/2010 e quella di oggi.. ma come ho fatto non funziona:

    dataoggi=day(now())&"/"&month(now())&"/"&year(now())

    sSql = "SELECT TOP 10"
    sSql = sSql + " * FROM giochi WHERE (giorno &/& mese &/& anno) AS data Between #01/05/2010# and #"&dataoggi&"# ORDER BY id DESC"


    Grazie mille

  2. #2
    com'è la struttura della tabella?

  3. #3
    nome tabella: "giochi"
    nome campi: giorno | mese | anno (tutti numerici)

    Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
    [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near '/'.
    /index.asp, line 233

  4. #4
    prova con

    codice:
    dataoggi = day(now()) & "/" & month(now()) & "/" & year(now())
    
    sSql = "SELECT TOP 10"
    sSql = sSql + " * FROM giochi WHERE (giorno + '/' + mese + '/' +' anno) AS data Between #01/05/2010# and #" & dataoggi & "# ORDER BY id DESC"
    
    ' solo per debug
    Response.Write "maGGica SQL...: " & sSql
    Response.Flush
    eventualmente poi posta quello che viene a video

  5. #5
    maGGica SQL...: SELECT TOP 10 * FROM giochi WHERE (giorno + '/' + mese + '/' + anno) AS data Between #01/05/2010# and #2/8/2011# ORDER BY id DESC

    Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
    [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'AS'.
    /index.asp, line 233

    O.o

  6. #6
    aiutino please

  7. #7
    sempre a frignare... togli la AS Data

  8. #8
    [Microsoft][ODBC SQL Server Driver][SQL Server]Error converting data type varchar to numeric.

    Come converto?

  9. #9
    sSql = "SELECT TOP 10"
    sSql = sSql + " * FROM giochi WHERE convert(datetime(10),giorno + '/' + mese + '/' + anno,111) Between 01/05/201 and " & dataoggi & " ORDER BY id DESC"

    Nulla da fare

    maGGica SQL...: SELECT TOP 10 * FROM giochi WHERE convert(DateTime(10),giorno + '/' + mese + '/' + anno,111) Between 01/05/201 and 2/8/2011 ORDER BY id DESC

    Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
    [Microsoft][ODBC SQL Server Driver][SQL Server]CAST or CONVERT: invalid attributes specified for type 'datetime'
    /index.asp, line 233

  10. #10

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 © 2026 vBulletin Solutions, Inc. All rights reserved.