format code appears twice error while inserting DATETIME from C# to Oracle DB

user545359 picture user545359 · Apr 19, 2013 · Viewed 18.4k times · Source

I am facing the below oracle error for the query

Insert Query:

INSERT INTO WINBACK_REFERRAL_CODES
  (REFERRAL_CODE, IS_DELETED,  CREATED_BY, 
   CREATED_DT,
   MODIFIED_BY,
   MODIFIED_DT, DELETED_BY,  DELETED_DT)
values
  ('sfsdfsd',     'N',         'LA\a03789',
   To_date('4/18/2013 3:57:47 PM','MM/DD/YYYY HH12:MI:SS AM'),
   '',
   To_date('','MM/DD/YYYY HH12:MI:SS AM'),
   '',
   To_date('4/18/2013 3:57:47 PM','MM/DD/YYYY HH12:MM:SS AM'));

ERROR MESSAGE:

Can someone please help me resolving this issue. I am trying to insert date and time in this format 4/18/2013 3:57:47 PM to oracle DB.

Answer

aquaraga picture aquaraga · Apr 19, 2013

To_date('4/18/2013 3:57:47 PM','MM/DD/YYYY HH12:MM:SS AM') should be rewritten to To_date('4/18/2013 3:57:47 PM','MM/DD/YYYY HH12:MI:SS AM'). Note the change from MM to MI.