zoukankan      html  css  js  c++  java
  • DB2 格式化输出 Date

    转自:http://www.cnblogs.com/zjun/archive/2012/02/15/2353054.html

    在Oracle中可以使用TO_CHAR()函数来将日期类型的数据转换成字符串输出,并且可以指定输出格式:
     
     TO_CHAR(date_expression, 'YYYY-MM-DD')
     TO_CHAR(date_expression, 'HH24:MI:SS')
     
    DB2也有TO_CHAR 和 TO_DATE函数,但只能提供固定的转换格式,而且数据类型是timestamp,如下:
     
    TO_CHAR (timestamp_expression,'YYY-MM-DD HH24:MI:SS')
    TO_DATE (string_expression, 'YYY-MM-DD HH24:MI:SS')
     
    如果要转换date的格式,直接用CHAR()函数,如下:
     
    CHAR(date_expression,ISO)
    CHAR(time_expression,ISO)
     
    ISO指定的日期格式是 yyyy-MM-dd,可以指定其他的格式:
     
    参数 日期格式 说明
    DEF   Use a date and time format associated with the territory code.
    EUR 30.01-2011 Use the IBM standard for Europe date and time format.
    ISO 2011-01-30 Use the date and time format of the International Standards Organization.
    JIS
    2011-01-30
    Use the date and time format of the Japanese Industrial Standard.
    LOC   Use the date and time format in local form associated with the territory code of the database.
    USA 01/30/2011 Use the IBM standard for U.S. date and time format.
     
     
     
    参考资料:
     
  • 相关阅读:
    python转换emoji字符串
    python位运算符详细介绍
    python制作动态排序图
    docker安装mysql
    yum安装centos-7版nginx
    pysimplegui模块实现倒计时UI框
    pysimplegui模块实现进度条
    python枚举的应用enum
    第0-0课
    SV -- Array 数组
  • 原文地址:https://www.cnblogs.com/wangpei/p/4465351.html
Copyright © 2011-2022 走看看