日期:2014-05-16  浏览次数:20520 次

db2截取字符串函数使用

CREATE TABLE
??? NEWTABLE
??? (
??????? COL1 INTEGER,
??????? COL2 VARCHAR(10),
??????? COL3 DATE,
??????? ADDTIME TIMESTAMP
??? )

?

?

?方法一:right(CHAR(COL3),5)

SELECT
??? COL1,
??? COL2,
??? right(CHAR(COL3),5)
FROM
??? ERPYXUSR.NEWTABLE

方法二:SUBSTR(CHAR(addtime),6) as 调度员完成时间

???
SELECT
??? COL1,
??? COL2,
?? SUBSTR(CHAR(addtime),6) as 调度员完成时间
FROM
??? ERPYXUSR.NEWTABLE

?

?

?

?

?

?截取只显示月日 时分 无秒

?

SELECT
??? COL1,
??? COL2,
??? concat(concat(left(left(SUBSTR(trim(CHAR(addtime)),6),11),5),' '),right(left(SUBSTR(trim(CHAR(addtime)),6),11),5)) as 调度员完成时间
FROM
??? ERPYXUSR.NEWTABLE

?

?

?