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"