Oracle Insert Date Data Common 2 problems and solutions _oracle

Source: Internet
Author: User

1. Invalid month problem

When you recently inserted a time into the database, Oracle reported an "invalid month issue" with the following SQL:

Copy Code code 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 incorrect date format.

Solution:
With select Sysdate from dual; To see the default date format, and then press the date format in the system, the input will solve the problem.

2, Date insertion format problem

When inserting date format data, report ORA-01861: text does not match the format string.
If you directly use the To_date (' 2007-12-28 10:07:24 ') without specifying a date format, you will get an error: ORA-01861: Text does not match the format string, you must specify a date format.
As follows:

Copy Code code as follows:
To_date (' 2007-12-28 10:07:24 ', ' yyyy-mm-dd hh24:mi:ss ')

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.