Proper Date Time format for MySQL from classic ASP code
on August 14th, 2009 at 9:25 pmTo properly put the date and time into a MySQL date field, you need to put it into the format of:
yyyy-mm-dd hh:mm:ss
Here is some code to do this in classic ASP for input into a MySQL table:
Dim testdate, testmonth, testday, ISODate
testdate = Request.Form("frmField5")
testmonth = Right(Month(testdate),2)
testday = Right(Day(testdate),2)
ISODate = Year(testdate) & "-" & testmonth & "-" & testday & " " & hour(testdate) & ":" & minute(testdate) & ":" & second(testdate)
The ISODate variable is in the correct format to insert in a MySQL UPDATE or INSERT SQL statement. Below is an example SQL string to UPDATE a date field in a MySQL table:
UPDATE myTable SET thisdate = 'ISODate' WHERE myID = 'thisID'
piano rentals…
Hello 😉 Thanks heaps for this indeed!… if anyone else has anything, it would be much appreciated. Great website Super Piano Links http://www.en.Grand-Pianos.org Enjoy!…