问题
i have a problem while inserting the date format like mm/dd/yyyy in mySQL.
It is showing the date format error.and my requirement is to enter like this format from front-end(coldfusion) and i am using mySQL5 as database.
any help would be greatly appriaciated.
Thanks
Yugal
回答1:
Make sure the date to save is a valid date and either use CreateODBCDate(yourDate) or CreateODBCDateTime(yourDate) or better let <cfqueryparam> do the work for you
INSERT into myTable
(myDate)
VALUES
(<cfqueryparam cfsqltype="cf_sql_date" value="#yourDate#">)
回答2:
Make sure you're entering dates in date columns and not string values, as the default cast of string --> date in the database could change at any time.
e.g.
insert into TableX (myDateCol) SELECT STR_TO_DATE('01,5,2013','%d,%m,%Y') ...
and not
insert into TableX (myDateCol) SELECT '05/01/2013' ...
or however that is constructed in coldfusion.
回答3:
I think you have to mention which format you are giving.
Insert into table TABLE values(XX,'TO_DATE('03-10-92','MM-DD-YY')',XXXXX);
来源:https://stackoverflow.com/questions/4469430/error-while-inserting-mm-dd-yyyy-date-in-mysql-in-coldfusion