Solution to ORA-01810 format code appears twice

Source: Internet
Author: User

When I was building a system last night, I needed to query the spans of two time ranges. I used the TO_DATE function and wrote it at the beginning.
SQL code
TO_DATE ('2017-09-24 00:00:00 ', 'yyyy-MM-DD HH: mm: ss ')
 
The result reported that the ORA-01810 format code had two errors. After the query, it was found that there was a problem with the formatting string,
The format should not be repeated twice. Otherwise, Oracle does not know which placeholder range to resolve the field,
The correct format should be like this. MI is used to represent minutes, instead of ss in java.
SQL code
TO_CHAR ('2017-09-01 00:00:00 ', 'yyyy-MM-DD HH: MI: ss ')
 
Later, we found that for the 24-hour system, HH was not supported well and changed to the following format:
SQL code
TO_CHAR ('2017-09-01 00:00:00 ', 'yyyy-MM-DD HH24: MI: ss ')
 
Formatting strings in ORACLE are case insensitive

Author: "Invincible little too old"
 

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.