I just want to format current date into yyyymmdd
in DB2.
I see the date formats available, but how can I use them?
SELECT CURDATE() FROM SYSIBM.SYSDUMMY1;
I dont see any straightforward way to use the above listed formats.
Any suggestion?
I just want to format current date into yyyymmdd
in DB2.
I see the date formats available, but how can I use them?
SELECT CURDATE() FROM SYSIBM.SYSDUMMY1;
I dont see any straightforward way to use the above listed formats.
Any suggestion?
Current date is in
yyyy-mm-dd
format. You can convert it intoyyyymmdd
format usingsubstring
function:This isn't straightforward, but
returns the current date in yyyy-mm-dd format. You would have to substring and concatenate the result to get yyyymmdd.
result: 20160510
Should work on both Mainframe and Linux/Unix/Windows DB2. Info Center entry for
VARCHAR_FORMAT()
.One more solution REPLACE (CHAR(current date, ISO),'-','')