Visualizzazione dei risultati da 1 a 7 su 7

Discussione: asp sql date...

  1. #1
    Utente di HTML.it L'avatar di biocco
    Registrato dal
    Sep 2003
    Messaggi
    486

    asp sql date...

    ho un problema a fare delle query sql con asp e i campi data. su access è impostato come capo data/ora e proprietà campo data generica

    codice:
    	if request("dal") <> vbnullstring and request("a") = vbnullstring then
    		sql = sql & "AND datainserimento >= " & FormatDateTime(request("dal"))
    	end if
    
    SELECT * FROM lista WHERE 1=1 AND datainserimento >= 01/01/2006
    
    me le tira fuori tutte anche quelle superiori a quella data	
    	
    	if request("dal") = vbnullstring and request("a") <> vbnullstring then
    		sql = sql & "AND datainserimento <= " & FormatDateTime(request("a"))
    	end if
    
    SELECT * FROM lista WHERE 1=1 AND datainserimento <= 01/01/2006
    
    non tira fuori nulla
    	
    	if request("dal") <> vbnullstring and request("a") <> vbnullstring then
    		sql = sql & " datainserimento Between " & FormatDateTime(request("dal")) & " And " & FormatDateTime(request("a"))
    	end if
    
    SELECT * FROM lista WHERE 1=1 datainserimento Between 01/09/2005 And 01/01/2006 
    Microsoft OLE DB Provider for ODBC Drivers error '80040e14' 
    
    [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression '1=1 datainserimento Between 01/09/2005 And 01/01/2006'. 
    
    /news/cercanews.asp, line 339
    non so piu cosa fare aiutatemi!!!

  2. #2
    le date vanno tra #
    EX Mentecatto - succube della Honda
    Le mie foto|HONDA CLUB ITALIA!|DARTH LEGNANZ!

  3. #3
    Utente di HTML.it L'avatar di biocco
    Registrato dal
    Sep 2003
    Messaggi
    486
    si lo so ma non fa nulla sembra che scambia mese col giorno cosa devo fare?

  4. #4
    Originariamente inviato da biocco
    si lo so ma non fa nulla sembra che scambia mese col giorno cosa devo fare?
    scrivere la data in formato anno/mese/giorno
    EX Mentecatto - succube della Honda
    Le mie foto|HONDA CLUB ITALIA!|DARTH LEGNANZ!

  5. #5
    Utente di HTML.it L'avatar di biocco
    Registrato dal
    Sep 2003
    Messaggi
    486
    OK COME SI FA?

  6. #6
    Utente di HTML.it L'avatar di biocco
    Registrato dal
    Sep 2003
    Messaggi
    486
    ho risolto cosi. pensavo di ricevere piu aiuto....

    codice:
    	
    	if request("dal") <> vbnullstring and request("a") = vbnullstring then
    		sql = sql & "AND datainserimento >= DateSerial(" & Right(request("dal"),4) & "," & Mid(request("dal"),4,2) & "," & Left(request("dal"),2) & ")"
    	end if	
    	
    	if request("dal") = vbnullstring and request("a") <> vbnullstring then
    		sql = sql & "AND datainserimento <= DateSerial(" & Right(request("a"),4) & "," & Mid(request("a"),4,2) & "," & Left(request("a"),2) & ")"
    	end if
    	
    	if request("dal") <> vbnullstring and request("a") <> vbnullstring then
    		sql = sql & "AND datainserimento Between DateSerial(" & Right(request("dal"),4) & "," & Mid(request("dal"),4,2) & "," & Left(request("dal"),2) & ") And DateSerial(" & Right(request("a"),4) & "," & Mid(request("a"),4,2) & "," & Left(request("a"),2) & ")"
    	end if

  7. #7
    non è meglio arrivare da soli alle soluzioni?
    EX Mentecatto - succube della Honda
    Le mie foto|HONDA CLUB ITALIA!|DARTH LEGNANZ!

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.