0
votes

I am trying to insert a row in my oracle table, but it is giving error 'Date format not recognized'. Details are as below. What is wrong in this?

create table "employee" ( 
     "emp_id" VARCHAR2(100 BYTE),
     "emp_name" VARCHAR2(100 BYTE),
     "hired_date" Date,
     CONSTRAINT "PK_employee" PRIMARY KEY ("emp_id")
);

Insert into employee values ( 'A1234', 'John Day', TO_DATE('07/20/2020 15:05:20', 'MM/DD/YYYY H24:MI:SS'));
2
It's not a good idea to force database object names to a specific case, unless your application specifically requires it. If you just name the table employee then it will be case-insensitive and much easier to work with. - William Robertson
Thanks @WilliamRobertson for pointing out! - Ajay Singh

2 Answers

3
votes

You are missing one 'H' use 'HH24'

Insert into "employee" values ( 'A1234', 'John Day', TO_DATE('07/20/2020 15:05:20', 'MM/DD/YYYY HH24:MI:SS'));
1
votes

Please change the format to MM/DD/YYYY HH24:MI:SS

Insert into "employee" values ( 'A1234', 'John Day', TO_DATE('07/20/2020 15:05:20', 'MM/DD/YYYY HH24:MI:SS'));

Below is the demo

https://dbfiddle.uk/?rdbms=oracle_11.2&fiddle=d4c0dda817bebcdd7c8d025c77cdc5c1