字符函数
数学函数
日期函数
转换函数
to_char(数字/日期)是把日期或数字转换为字符串
- 将数字转换成指定格式
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'
复制
- 将日期转换成指定格式
to_char(sysdate, 'yyyy/mm/dd');--would return '2003/07/09'
select to_char(sysdate, 'yyyy-mm-dd hh24:mi:ss') from a; ------> 2015-08-28 14:43:15
select to_char(sysdate, 'yyyy-mm-dd hh12:mi:ss') from a; ------> 2015-08-28 02:43:15
to_char(sysdate, 'yyyy/mm/dd');--would return '2003/07/09'
to_char(sysdate,'dd-mm-yyyy')--按dd-mm-yyyy格式转换23-05 -2016
to_char(sysdate, 'Month DD, YYYY');--would return '10月 21, 2015'
to_char(sysdate, 'FMMonth DD, YYYY');--would return 'July 9, 2003'
to_char(sysdate, 'MON DDth, YYYY');--would return 'JUL 09TH, 2003'
to_char(sysdate, 'FMMON DDth, YYYY');--would return 'JUL 9TH, 2003'
to_char(sysdate, 'FMMon ddth, YYYY');--would return 'Jul 9th, 2003'
to_char(sysdate, 'FMMonth DD, YYYY');--would return 'July 9, 2003'
to_char(sysdate, 'FMMON DDth, YYYY');--would return 'JUL 9TH, 2003'
to_char(sysdate, 'FMMon ddth, YYYY');--would return 'Jul 9th, 2003'
复制
to_number(字符串) 将给出的字符转换为数字
select to_number('123') from a ;
复制