日期:2014-05-16  浏览次数:20376 次

Oralce toChar的用法。

TO_CHAR中很多人格式化日期时会用 TO_CHAR(date,'YYYYMMDD HH24:MM:SS')

小心哦,这个格式是错的,被Java毒害了。

正确的格式串是:YYYYMMDD HH24:MI:SS

?

The following are number examples for the to_char function.

to_char(1210.73, '9999.9') would return '1210.7'
to_char(1210.73, '9,999.99') would return '1,210.73'
to_char(1210.73, '$9,999.00') would return '$1,210.73'
to_char(21, '000099') would return '000021'

?

The following is a list of valid parameters when the to_char function is used to convert a date to a string. These parameters can be used in many combinations.

? ParameterExplanation
YEAR Year, spelled out
YYYY 4-digit year
YYY
YY
Y
Last 3, 2, or 1 digit(s) of year.
IYY
IY
I
Last 3, 2, or 1 digit(s) of ISO year.
IYYY 4-digit year based on the ISO standard
Q Quarter of year (1, 2, 3, 4; JAN-MAR = 1).
MM Month (01-12; JAN = 01).
MON Abbreviated name of month.
MONTH Name of month, padded with blanks to length of 9 characters.
RM Roman numeral month (I-XII; JAN = I).
WW Week of year (1-53) where week 1 starts on the first day of the year and continues to the seventh day of the year.
W Week of month (1-5) where week 1 starts on the first day of the month and ends on the seventh.
IW Week of year (1-52 or 1-53) based on the ISO standard.