zoukankan      html  css  js  c++  java
  • 05-oralce转换函数

    to_char() 设置日期的显示格式

    to_char()  进行数字格式化{如:to_char(987654321.789,'999,999,999,999,999.9999') 将数字三位一逗号显示}

    --to_char(sysdate,'yyyy-mm-dd')日期以年月日显示

    --to_char(sysdate,'mm') 只取出日期中的月份

    --年月日显示

    SQL> select sysdate,to_char(sysdate,'yyyy-mm-dd') from dual;

    SYSDATE TO_CHAR(SY
    ------------ ----------
    13-APR-19 2019-04-13

    --日月年显示

    select sysdate,to_char(sysdate,'dd-mm-yyyy') 日月年 from dual;

    select sysdate,
    to_char(sysdate,'yyyy') 单取年,
    to_char(sysdate,'mm') 单取月,
    to_char(sysdate,'dd') 单取日
    from dual;

    --查询雇佣日期为2月的员工信息
    select * from emp where to_char(hiredate,'mm')='02';

    --to_char() 将数字格式化显示

    select
    to_char(987654321.789,'999,999,999,999,999.9999') 将数字三位一逗号显示,
    to_char(987654321.789,'000,000,000,000,000.0000')将数字三位一逗号显示
    from dual;

    select
    to_char(987654321.789,'L999,999,999,999,999.9999') L以本地环境显示货币符号,
    to_char(987654321.789,'$000,000,000,000,000.0000')设置以$符号显示货币
    from dual;

    --to_date() 将字符串转换为日期

    select
    to_date('1922-10-15','yyyy-mm-dd') 字符串转换为日期
    from dual;

    select sysdate,
    to_char(sysdate,'yyyy-mm-dd hh:mi:ss') 以年入月日显示,
    to_char(/*'1992-11-2'*/sysdate,'mm') 取出日期中的月份,
    to_char('987654321.345','999,999,999,999.9999') 格式化字符串3位1逗号显示,
    to_date('1992-11-2','yyyy-mm-dd') 将字符转为日期
    from dual;

  • 相关阅读:
    3524: [Poi2014]Couriers -- 主席树
    bzoj 2190: [SDOI2008]仪仗队 -- 欧拉函数
    模板 -- 树链剖分
    bzoj 1823: [JSOI2010]满汉全席 -- 2-sat
    bzoj 1704: [Usaco2007 Mar]Face The Right Way 自动转身机 -- 贪心
    bzoj 1231: [Usaco2008 Nov]mixup2 混乱的奶牛 -- 状压DP
    redis 主从复制
    redis 事务
    redis持久化——AOF
    redis 持久化 ——RDB
  • 原文地址:https://www.cnblogs.com/joeshang/p/10703072.html
Copyright © 2011-2022 走看看