SELECT SUBSTR(CAST(YEAR(SOMEDATE) AS VARCHAR(4)),2,2) AS "YY" FROM SOMESCHEMA.FOO;
Gets me the following error:
- [Code: -104, SQL State: 42601] ILLEGAL SYMBOL “,2”. SOME SYMBOLS THAT MIGHT BE LEGAL ARE:. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.26.14
- [Code: -514, SQL State: 26501] THE CURSOR SQL_CURLH200C1 IS NOT IN A PREPARED STATE. SQLCODE=-514, SQLSTATE=26501, DRIVER=4.26.14
And no matter what I change, the error stays..
Advertisement
Answer
The solution for DB2 z/OS is:
VARCHAR_FORMAT(SOMEDATE, 'YY') AS "YY"