Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 15

Discussione: Query update in mySQL

  1. #1
    Utente di HTML.it L'avatar di [trodat]
    Registrato dal
    Oct 2004
    Messaggi
    2,135

    Query update in mySQL

    Ciao.

    Questa query per un db mysql va in errore:

    SQL2 = "UPDATE tbl set DataUltimoAccesso = '"&Date()&"' where ID = "& id
    cn.Execute(SQL2)

    Tipo di errore:
    Microsoft OLE DB Provider for ODBC Drivers (0x80040E31)
    [MySQL][ODBC 3.51 Driver][mysqld-5.0.24-community-nt]Incorrect date value: '23/08/2006' for column 'DataUltimoAccesso' at row 15
    perchè? il campo dataultimoaccesso nel db è date.

    grazie
    Lo Stato dà un posto. L’impresa privata dà un lavoro. – Indro Montanelli

  2. #2
    togli gli apici
    e metti #
    Ah, Jedis! I had no ideas! What can i do for you, honored Jedis?

    I'm not Jedi. I'm a guy with a lighsaber and a few questions.

  3. #3
    Utente di HTML.it L'avatar di [trodat]
    Registrato dal
    Oct 2004
    Messaggi
    2,135
    VVoVe:

    Ma è mySQL non è Access... cmq con gli apici:

    Tipo di errore:
    Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
    [MySQL][ODBC 3.51 Driver][mysqld-5.0.24-community-nt]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
    Lo Stato dà un posto. L’impresa privata dà un lavoro. – Indro Montanelli

  4. #4
    prova formati diversi

    MM/DD/YYYY
    YYYY/MM/DD
    MM-DD-YYYY
    YYYY-MM-DD



  5. #5
    Utente di HTML.it L'avatar di [trodat]
    Registrato dal
    Oct 2004
    Messaggi
    2,135
    Emmmmm...

    Mi hanno sbrindellato il cervello (non ne avevo bisogno, sono già sbrindellato per fatti mia) dicendomi che con mysql avrei risolto definitivamente il problema del formato date che si presenta invece con access...

    Adesso che?
    Mi ritrovo ad usare le funzioni di conversioni date e tempo (imente bontà sua) come facevo in Access ? Ma che significa???

    codice:
    function getGMTDate(argDate,argGMT)
    	getGMTDate = dateadd("h",argGMT,argDate)
    end function
    
    function formatGMTDate(argDate, argGMT, argFormat)
    	dim tmpdate,tmpdateoutput
    	tmpdate = getGMTDate(argDate,argGMT)
    	
    	tmpdateoutput = argFormat
    	tmpdateoutput = replace(tmpdateoutput,"dd",right("0" & day(tmpdate),2))
    	tmpdateoutput = replace(tmpdateoutput,"mm",right("0" & month(tmpdate),2))
    	tmpdateoutput = replace(tmpdateoutput,"yyyy",year(tmpdate))
    	tmpdateoutput = replace(tmpdateoutput,"yy",right(year(tmpdate),2))
    	
    	tmpdateoutput = replace(tmpdateoutput,"h",right("0" & hour(tmpdate),2))
    	tmpdateoutput = replace(tmpdateoutput,"m",right("0" & minute(tmpdate),2))
    	tmpdateoutput = replace(tmpdateoutput,"s",right("0" & second(tmpdate),2))	
    	formatGMTDate = tmpdateoutput
    end function
    
    
    DataOdierna =  formatGMTDate(date(),0,"yyyy-mm-dd")
    tempo = formatGMTDate(time(),0,"h:m:s")
    Lo Stato dà un posto. L’impresa privata dà un lavoro. – Indro Montanelli

  6. #6
    uffa... devo proprio farla sta pillola sulle date :P

    cmq ho fatto una funzione apposta, che non c'entra con quelle li

    codice:
    function formatDBDate(argDate,argDB)
    
    	dim tmpdate,tmpdateoutput
    	tmpdate = argDate
    	
    	select case argDB
    		case "mdb"
    		tmpdateoutput = "#yyyy-mm-dd h:m:s#"
    		case "mysql"
    		tmpdateoutput = "'yyyy-mm-dd h:m:s'"
    	end select
    	
    	tmpdateoutput = replace(tmpdateoutput,"dd",right("0" & day(tmpdate),2))
    	tmpdateoutput = replace(tmpdateoutput,"mm",right("0" & month(tmpdate),2))
    	tmpdateoutput = replace(tmpdateoutput,"yyyy",year(tmpdate))
    	tmpdateoutput = replace(tmpdateoutput,"yy",right(year(tmpdate),2))
    	
    	tmpdateoutput = replace(tmpdateoutput,"h",right("0" & hour(tmpdate),2))
    	tmpdateoutput = replace(tmpdateoutput,"m",right("0" & minute(tmpdate),2))
    	tmpdateoutput = replace(tmpdateoutput,"s",right("0" & second(tmpdate),2))
    	
    	formatDBDate = tmpdateoutput
    	
    end function
    
    SQL = "UPDATE tuatabella SET tuocampodata = " & formatDBDate(tuadata,"mysql") & ";"
    '...
    ovviamente se passi alla funzione "mdb" ti da il formato per MDB

    problema risolto...
    san imente saluta

    * http://simonecingano.it *

  7. #7
    non per rompere le palle alla gente, ma leggere i manuali (online) di MySql per sapere come funziona il db no?

  8. #8
    Originariamente inviato da santino83_11_04
    non per rompere le palle alla gente, ma leggere i manuali (online) di MySql per sapere come funziona il db no?
    eddddddaaaaiiii... per una volta che qualcuno mi da l'occasione di mettere una mia bella funzioncina!!!!!!!!!

    san imente saluta

    * http://simonecingano.it *

  9. #9
    Utente di HTML.it L'avatar di [trodat]
    Registrato dal
    Oct 2004
    Messaggi
    2,135
    Originariamente inviato da imente
    eddddddaaaaiiii... per una volta che qualcuno mi da l'occasione di mettere una mia bella funzioncina!!!!!!!!!

    Forza Imente fatti rispettare !!!!
    Santino tu non mi rompi le balle... sono quelli che m'hanno fregato sulle date in mysql !!!!
    Lo Stato dà un posto. L’impresa privata dà un lavoro. – Indro Montanelli

  10. #10
    funziona ora?
    san imente saluta

    * http://simonecingano.it *

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.