AndersonHitchen
asked on
Alter Date column in MySQL - assistance
I am getting the following error on an image upload page that writes to a mysql database.
[ODBC 5.1 Driver][mysqld-5.6.22-log] Incorrect date value: ' 4/6/2015' for column
I had to recreate the table as it was missing so I am guessing that I created the column incorrectly and now need to alter it.
Any help would be appreciated.
[ODBC 5.1 Driver][mysqld-5.6.22-log]
I had to recreate the table as it was missing so I am guessing that I created the column incorrectly and now need to alter it.
Any help would be appreciated.
TRY '2015/06/04 00:00:00'
You may need to format the date.
Use MyNewDate to submit to mysql.
MyDate=cdate("4/6/2015")
MyNewDate = year(MyDate)&"-"&right("0"&month(MyDate),2)&"-"&right("0"&day(MyDate),2)
Use MyNewDate to submit to mysql.
you may want to consider using parameterized queries, thus eliminating issues like this
https://www.experts-exchange.com/Programming/Languages/Scripting/ASP/A_3626-ASP-Classic-Using-Parameterized-Queries.html
https://www.experts-exchange.com/Programming/Languages/Scripting/ASP/A_3626-ASP-Classic-Using-Parameterized-Queries.html
I was suggesting that the date may need to be quoted and in the standard format to be acceptable.
ASKER
Hi Again
As in my question I only need to alter the table not the code as the code works fine normally. Its only due to the fact that I have had to recreate the table for the upload data which has a datefield in it and I have not created that column correctly.
I was hoping that someone might have a solution to this.
Here is a snipet of code from the upload page that relates to the date which again shows that I only need to alter the date column to suit input.
Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnectio n = MM_connilease_STRING
' 1 2 3 4 5
MM_editCmd.CommandText = "INSERT INTO carimages (makeID, modelID, modelYear, fldImage, dateAdded) VALUES (?, ?, ?, ?, ?)"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Appe nd MM_editCmd.CreateParameter ("param1", 5, 1, -1, MM_IIF(UploadFormRequest(" make"), UploadFormRequest("make"), null)) ' adDouble
MM_editCmd.Parameters.Appe nd MM_editCmd.CreateParameter ("param2", 5, 1, -1, MM_IIF(UploadFormRequest(" models"), UploadFormRequest("models" ), null)) ' adDouble
MM_editCmd.Parameters.Appe nd MM_editCmd.CreateParameter ("param3", 202, 1, 50, UploadFormRequest("year")) ' adVarWChar
MM_editCmd.Parameters.Appe nd MM_editCmd.CreateParameter ("param4", 202, 1, 50, UploadFormRequest("img1")) ' adVarWChar
MM_editCmd.Parameters.Appe nd MM_editCmd.CreateParameter ("param5", 202, 1, 50, UploadFormRequest("Selecte dDate")) ' adVarWChar
MM_editCmd.Execute
MM_editCmd.ActiveConnectio n.Close
Cheers for the replies
As in my question I only need to alter the table not the code as the code works fine normally. Its only due to the fact that I have had to recreate the table for the upload data which has a datefield in it and I have not created that column correctly.
I was hoping that someone might have a solution to this.
Here is a snipet of code from the upload page that relates to the date which again shows that I only need to alter the date column to suit input.
Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnectio
' 1 2 3 4 5
MM_editCmd.CommandText = "INSERT INTO carimages (makeID, modelID, modelYear, fldImage, dateAdded) VALUES (?, ?, ?, ?, ?)"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Appe
MM_editCmd.Parameters.Appe
MM_editCmd.Parameters.Appe
MM_editCmd.Parameters.Appe
MM_editCmd.Parameters.Appe
MM_editCmd.Execute
MM_editCmd.ActiveConnectio
Cheers for the replies
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The last parameter should be
MM_editCmd.Parameters.Appe nd MM_editCmd.CreateParameter ("param5", 135, 1, -1, UploadFormRequest("Selecte dDate")) ' adVarWChar
MM_editCmd.Parameters.Appe