'Convert current date to char in DB2
I have a INSERT + SELECT statement. One column is a VARCHAR but must be filled with a date with 'yyyyMMdd' format in 3 different dialect.
With SQL server and Oracle there's no problem, but in Db2 I didn't find anything to do this stuff.
In SQLServer is CONVERT(VARCHAR,S.DT_NASCITA,112)
In Oracle is TO_CHAR(S.DT_NASCITA,'YYYYMMDD')
Any1 can help me pls ?
ty in advice !
Solution 1:[1]
Fix in a very bad way. This way work in all distro, seems
SELECT SUBSTR(CHAR(CURRENT DATE, ISO),1,4) || SUBSTR(CHAR(CURRENT DATE, ISO),6,2) || SUBSTR(CHAR(CURRENT DATE, ISO),9,2) FROM SYSIBM.SYSDUMMY1
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |