2012年3月20日 星期二

[INFORMIX] 日期轉民國年


SELECT substr(CAST(1000+YEAR(reportdate)-1911 AS CHAR(4)),-3),
substr(CAST(100+MONTH(reportdate) AS CHAR(3)),-2) ,
substr(CAST(100+DAY(reportdate) AS CHAR(3)),-2),

substr(CAST(1000+YEAR(reportdate)-1911 AS CHAR(4)),-3) ||
substr(CAST(100+MONTH(reportdate) AS CHAR(3)),-2) ||
substr(CAST(100+DAY(reportdate) AS CHAR(3)),-2)
FROM Totfa
WHERE ReportMonth = 10102

結果:
(expression) (expression)_1 (expression)_2 (expression)_3
101 03 05 1010305