Oracle中char到Date和Number的转换

来源:百度文库 编辑:神马文学网 时间:2024/04/19 19:01:19
Select To_Char(To_Date('1312324', 'j'), 'jsp') From Dual;
one million three hundred twelve thousand three hundred twenty-four
j从耶酥日开始的累计天数,jsp的含义出自那里,在oracle官方文档库里没有。
另附上char<->number ,char<->date的官方格式,希望对大家有所帮助。
char<->number
, 分隔符(一般千位)
. 小数点
$ 美圆符号前导
0 0999 前导0(5位) length(to_char(12,'000'))=4
9990 后缀0(5位)
9 9999 前导空格(5位) length(to_char(12,'999'))=4
B
C C999 国际标准货币符号 to_char(0.122,'C90.99')=' CNY0.12'
D 99D99 小数标记,默认为"."
EEEE 0.0EEEE 科学计数发(必须4个E或e) to_char(0.122,'0.9eeee')=' 1.2E-01'
FM fm90.9 无前导后缀空格 to_char(.122,'FM90.99')='0.12'
G 9G999 分隔符(默认位",") to_char(1234,'9g999')=' 1,234'
L L9999 人民币代码 to_char(1234,'fmL99,999')='RMB1,234'
Mi 999Mi 符号后置 to_char(1234,'fm999,999mi')='1,234-'
PR 999PR 括号表示负数 to_char(-1234,'fm999,999pr')='<1,234>'
RN RN|rn 罗马数字 to_char(12,'fmRN')='XII' (1<=n<=3999)
S 9999S 显示正负号 to_char(-12,'FM999S')='12-'
s9999 to_char(12,'FMs999')='+12'
TM TM
U U9999 欧圆代码 to_char(12,'FMu990')='RMB12' 与Nls_Dual_Currency有关
V 99V99 扩大10的n倍 to_char(123,'fm999v9990')='1230000'
X XXXX 十六进制 to_char(1234,'FmXXXX')='4D2'
to_char(123.678,'999,999.9999')=' 123.6780'
to_char(0.022,'999.000')=' .022'
to_char(123.678,'000,000.0000')='000,123.6780'
to_char(0.02,'000.999')=' 000.020'
to_char(123.678,'000,000.00')=' 000,123.68'
to_char(123.678,123.678,'99')='###' Ora-12702
to_char(123.678,'$999,00')=' $1,24'
-----------------------------------------------------------------------------------------------
char<->date
- , . ; : 间隔符 to_char(sysdate,'yyyy-mm/ss. hh24 ;mi:ss')='2004-10/38. 21 ;34:38'
"text" to_char(Sysdate,'yyyy"年"mm"月"dd"日"')='2004年10月26日'
AD|A.D.|BC|B.C. 公元(前) to_char(Sysdate,'B.c.yyyy"年"')='公元2004年'
CC|SCC 世纪 to_char(Sysdate,'Scc"世纪"yyyy.mm')='21世纪2004.10'
在21世纪仅用两位表示20世纪的时间
Y,YYY|YYY|YY|Y 年 to_char(Sysdate,'yy')='04'
IYYY|IYY|IY|I 年(ISO) to_char(Sysdate,'Iyy')='004'
RR|RRRR to_date('80','rr')=1980.10.01 默认月为当前月的首日
to_date('80','yy')=2080.10.01
Year|SYear 英文年 to_char(Sysdate,'Year')='two thousand four'
to_char(Sysdate,'SYear')=' Two Thousand Four'
Q 季度(1-4) to_char(Sysdate,'yyyy.mm "第"q"季度"')='2004.10 第4季度'
MM 月份(01-12)
Month|Mon 月份 to_char(Sysdate,'yyyy.mon.dd q iw dy')='2004.10月.26 4 44 星期二'
RM 罗马月份 to_char(Sysdate,'yyyy.mm Rm')='2004.10 X'
IW 周数(1-53) to_char(Sysdate,'yyyy.mm.dd"第"iW"周"')='2004.10.26第44周'
WW|W 周数
Day|Dy 星期 to_char(Sysdate,'yyyy.mm.dd Day')='2004.10.26 星期二'
D 星期(1-7) to_char(Sysdate,'D')='3' 星期二
DD 天(1-31) to_char(Sysdate,'yyyy.mm.dd')='2004.10.26'
DDD 天(1-366) to_char(Sysdate,'yyyy.mm.dd ddd')='2004.10.26 300'
J 耶苏日 to_char(Sysdate,'j')='2453305' 自BC14712年算起
AM|A.M.|PM|P.M. 上(下)午 to_char(Sysdate,'AM hh24:mi:ss')='下午 21:50:57'
HH|HH12 小时(1-12) to_char(Sysdate,'aMhh:mi:ss')='下午10:08:23'
HH24 小时(0-23) to_char(Sysdate,'P.M.hh:mi:ss')='下午10:11:04'
Mi 分钟(0-59)
SS 秒(0-59)
SSSSS 秒(0-86399) to_char(Sysdate,'hh24:mi:ss sssss')='22:35:59 81359' 自零时累计值
TZD|TZH|TZM|TZR 时区
E|EE|FF(1..9)|X