Two Common Problems and Solutions of Oracle Inserting Date Data

  • 2021-11-13 18:40:57
  • OfStack

1. Invalid month problem

Recently, when inserting time into the database, Oracle reported "invalid month problem", and the specific SQL is as follows:

INSERT INTO TS_COUNT (   
    ID , CNAME, STARTTIME, ENDTIME,VALUE  
) VALUES (  
    1, 'John', '01/06/2013', '02/06/2013', 800  
); 

Error: ORA-01843: Invalid month. This is due to the incorrect date format.

Solution:
select sysdate from dual; Check the default date format, and then press the date format in the system, and enter it to solve the problem.

2. Date insertion format

When inserting date format data, report ORA-01861: The text does not match the format string.
If you do not specify a date format directly as a string, or if you use to_date ('2007-12-28 10:07:24'), an error will be reported: ORA-01861: The text does not match the format string, you must specify a date format.
As follows:

to_date('2007-12-28 10:07:24' , 'yyyy-mm-dd hh24:mi:ss')


Related articles: