Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DB2 Date format

Tags:

I just want to format current date into yyyymmdd in DB2.

I see the date formats available, but how can I use them?

http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=%2Fcom.ibm.db2z10.doc.intro%2Fsrc%2Ftpc%2Fdb2z_datetimetimestamp.htm

SELECT CURDATE() FROM SYSIBM.SYSDUMMY1;

I dont see any straightforward way to use the above listed formats.

Any suggestion?

like image 209
zod Avatar asked Apr 25 '12 17:04

zod


1 Answers

SELECT VARCHAR_FORMAT(CURRENT TIMESTAMP, 'YYYYMMDD')
FROM SYSIBM.SYSDUMMY1

Should work on both Mainframe and Linux/Unix/Windows DB2. Info Center entry for VARCHAR_FORMAT().

like image 81
bhamby Avatar answered Sep 21 '22 02:09

bhamby