i am almost emberassed to ask this i am having trouble entering the query below, i want to enter a date value with a different format (dd/mm/yy). mysql is tired and doesnt want to work with me entering a value, but in the wrong format. i put the string 03-08-2009 in a variable(java) and use ? prepared satement to execute the query .
INSERT INTO project (code, sdatum) VALUES(
12, STR_TO_DATE('03-08-2009', '%d/%m/%Y'));
this is what mysql inserts into the column table
’12’,’2009-08-03′
PS: i am using the workbench
(Upgrading to an answer)
As documented under The
DATE,DATETIME, andTIMESTAMPTypes:If you want to retrieve dates formatted in some other way, you must apply
DATE_FORMAT()to your select expression: