In Oracle date usage, the formats of the parameters _ date ("string to be converted", "format to be converted") must match with each other. Otherwise, an error is reported. For this question, the following articles provide relevant solutions, and hope you will gain some benefits.
That is, the first parameter is interpreted according to the format of the second parameter.
To_char (date, "conversion format") converts a given date according to the "conversion format.
Conversion format:
Y indicates the last yy Of The year. yyy indicates the last two digits of the year. yyyy indicates the last three digits of the year. yyyy indicates the year in four digits.
For month: mm uses two digits to represent the month. mon uses the abbreviation such as January 1, November or nov. month uses the full name such as January 1, November or November.
Dd indicates the day of the month; ddd indicates the day of the year; dy indicates the day of the week, such as Friday or fri; day indicates the day of the week.
For example, Friday or Friday.
Hh 2-digit represents the hour 12-digit; hh24 2-digit represents the hour 24-hour
Indicates minute. mi 2-digit indicates minute.
Indicating second: two-digit ss indicates 60 seconds
Indicates the quarter. q indicates the quarter 1-4)
In Oracle date usage, ww is also used to indicate the week w of the current year.
Time range in the 24-hour system: 00: 00: 00-23:59:59
Time range in the 12-hour format: 1: 00: 00-12:59:59
For example:
- select to_char(sysdate,'yy-mm-dd hh24:mi:ss') from dual
Display: 08-11-07 13:22:42
- select to_date('2005-12-25,13:25:59','
yyyy-mm-dd,hh24:mi:ss') from dual
Display: 13:25:59
If you write the above:
- select to_date('2005-12-25,13:25:59','yyyy-mm-dd,hh:mi:ss')
from dual
An error is reported because the hour hh is in 12-digit format and the value 13 is invalid and cannot be matched. The preceding content describes the usage of Oracle date in 2010-01-20 09: 42to_date ("string to be converted", "format to be converted"). The formats of the two parameters must match, hope you have some gains.