postgres中字符转换函数to_timestamp字符串转时间,to_char转字符串,转数字to_number

一,字符串转换

1, 字符串转时间:to_timestamp

to_timestamp('1900-01-01 00:00:00.000','YYYY-mm-dd HH24:MI:SS.MS')

将第一个整型参数转换成时间    第一个参数可以修改值

2, 时间转字符串 to_char

to_char(current_timestamp, 'yyyy-mm-dd HH24:MI:SS');

输出现在的时间  第二个参数为格式

3, 字符串转数字to_number

to_number('bc7123','9999')第一个参数必须为整数,999也可以换成1   给几个就前面转几个

字母无效  所以这个只转换71    如果是to_number('7123','9999')则转换7123

4,数字转字符串to_char

to_char(1234, '9999999999') 运行结果如图


to_char(1234, '99') 运行结果如图




猜你喜欢

转载自blog.csdn.net/VR_dancy/article/details/80020012