格式化函数提供一套有效的工具用于把各种数据类型(日期/时间,int,float,numeric)转换成格式化的字符串以及反过来从格式化的字符串转换成原始的数据类型。
函数 | 返回 | 描述 | 例子 |
---|
to_char(timestamp, text) | text | 把 timestamp 转换成 string | to_char(timestamp 'now','HH12:MI:SS') |
to_char(int, text) | text | 把 int4/int8 转换成 string | to_char(125, '999') |
to_char(float, text) | text | 把 float4/float8 转换成 string | to_char(125.8, '999D9') |
to_char(numeric, text) | text | 把 numeric 转换成 string | to_char(numeric '-125.8', '999D99S') |
to_date(text, text) | date | 把 string 转换成 date | to_date('05 Dec 2000', 'DD Mon YYYY') |
to_timestamp(text, text) | date | 把 string 转换成 timestamp | to_timestamp('05 Dec 2000', 'DD Mon YYYY') |
to_number(text, text) | numeric | 把 string 转换成 numeric | to_number('12,454.8-', '99G999D9S') |
原文地址:
http://www.cnblogs.com/reborter/archive/2008/11/28/1343195.html