error while inserting mm-dd-yyyy date in mysql in coldfusion

ε祈祈猫儿з 提交于 2019-12-13 02:59:09

问题




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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!