ORA-01855: AM/A.M. or PM/P.M. required

不羁的心 提交于 2019-12-02 01:55:53

Your format mask must match the format of the string you are converting. So you would either want to add SS to the format mask or remove the seconds from the string

INSERT INTO TBL(ID,START_DATE) 
  values (123, TO_DATE ('3/13/2012 9:22:00 AM', 'MM/DD/YYYY HH:MI:SS AM'))

or

INSERT INTO TBL(ID,START_DATE) 
  values (123, TO_DATE ('3/13/2012 9:22 AM', 'MM/DD/YYYY HH:MI:SS AM'))

If you want to accept a string that contains seconds but you don't want to store the seconds in the database (in which case Oracle will always store 0 for the seconds), you can use the TRUNC function

INSERT INTO TBL(ID,START_DATE) 
  values (123, TRUNC( TO_DATE ('3/13/2012 9:22:00 AM', 'MM/DD/YYYY HH:MI:SS AM'), 'MI') )

I got the same error when running the form builder, It was fixed by changing the Filed DataType from TIME to CHAR.

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