Board logo

标题: Oracle中to_char()函数的用法 [打印本页]

作者: xiexie    时间: 2020-6-29 09:26     标题: Oracle中to_char()函数的用法

日期转换:
to_char(date,'格式')
select to_date('2005-01-01 ','yyyy-MM-dd') from dual;
select to_char(sysdate,'yyyy-MM-dd HH24:mi:ss') from dual;


处理数字:
to_char(number,'格式')
select to_char(88877) from dual;
select to_char(1234567890,'999,999,999,999.9999') from dual;

select TO_CHAR(123,'$99,999.9') from dual;

用于进制转换:将10进制转换为16进制
select to_char(4567,'xxxx') from dual;
select to_char(123,'xxx') from dual;

  1. 1 //// to_char 例子
  2. 2 输入 输出
  3. 3 to_char(now(),'Day, HH12:MI:SS') 'Tuesday , 05:39:18'
  4. 4 to_char(now(),'FMDay, HH12:MI:SS') 'Tuesday, 05:39:18'
  5. 5 to_char(-0.1,'99.99') ' -.10'
  6. 6 to_char(-0.1,'FM9.99') '-.1'
  7. 7 to_char(0.1,'0.9') ' 0.1'
  8. 8 to_char(12,'9990999.9') ' 0012.0'
  9. 9 to_char(12,'FM9990999.9') '0012'
  10. 10 to_char(485,'999') ' 485'
  11. 11 to_char(-485,'999') '-485'
  12. 12 to_char(485,'9 9 9') ' 4 8 5'
  13. 13 to_char(1485,'9,999') ' 1,485'
  14. 14 to_char(1485,'9G999') ' 1 485'
  15. 15 to_char(148.5,'999.999') ' 148.500'
  16. 16 to_char(148.5,'999D999') ' 148,500'
  17. 17 to_char(3148.5,'9G999D999') ' 3 148,500'
  18. 18 to_char(-485,'999S') '485-'
  19. 19 to_char(-485,'999MI') '485-'
  20. 20 to_char(485,'999MI') '485'
  21. 21 to_char(485,'PL999') '+485'
  22. 22 to_char(485,'SG999') '+485'
  23. 23 to_char(-485,'SG999') '-485'
  24. 24 to_char(-485,'9SG99') '4-85'
  25. 25 to_char(-485,'999PR') '<485>'
  26. 26 to_char(485,'L999') 'DM 485
  27. 27 to_char(485,'RN') ' CDLXXXV'
  28. 28 to_char(485,'FMRN') 'CDLXXXV'
  29. 29 to_char(5.2,'FMRN') V
  30. 30 to_char(482,'999th') ' 482nd'
  31. 31 to_char(485, '"Good number:"999') 'Good number: 485'
  32. 32 to_char(485.8,'"Pre-decimal:"999" Post-decimal:" .999') 'Pre-decimal: 485 Post-decimal: .800'
  33. 33 to_char(12,'99V999') ' 12000'
  34. 34 to_char(12.4,'99V999') ' 12400'
  35. 35 to_char(12.45, '99V9') ' 125'

 


[ 本帖最后由 xiexie 于 2020-6-29 09:38 编辑 ]




欢迎光临 PHP开发笔记 (http://phpvi.com/) Powered by Discuz! 6.1.0