-- 日期格式转换:
20160422183321
>>>
2016-04-22 18:33:21
-- 转换SQL:
SELECT
TO_CHAR(TO_DATE('20160422183321','YYYYMMDDHH24MISS'),'YYYY-MM-DD
HH24:MI:SS') AS RQ FROM DUAL
-- 重点:
时间格式中小时后要加24,不然会报错:ORA-01849: hour must be between 1 and 12
错误信息提示:ORA-01849:
hour must be between 1 and 12
-- 金额格式转换:
6000
>>>
6,000.00
-- 转换SQL:
SELECT TRIM(TO_CHAR('6000','999,999,999,999,999.00' )) AS JE
FROM DUAL
--
金额格式转换:
123456.78
>>>
123,456.78
SELECT TRIM(TO_CHAR('123456.78','999,999,999,999,999.00' )) AS
JE FROM DUAL
--重点:
要保证9的个数比要转换的字段要长,不然查询结果全是#号
错误展示结果
TRIM方法要保留,不然会在查询结果左侧补空9的个数减要转换金额的个数为的空
查询结果为空的信息