db2 => select current date from sysibm.sysdummy1
1
----------
2011-03-13
已選取 1 個記錄。
db2 => SELECT CURRENT TIMESTAMP FROM SYSIBM.SYSDUMMY1
1
--------------------------
2011-03-13-18.00.25.177000
db2 => select date ( days( current date) -1 ) yesterday_date from sysibm.sysdumm
y1
YESTERDAY_DATE
--------------
2011-03-12
已選取 1 個記錄。
db2 => select year(current date) 年,month(current date) 月,day(current date) 日
from sysibm.sysdummy1
年 月 日
----------- ----------- -----------
2011 3 13
已選取 1 個記錄。
db2 => select char( year(current date) ) from sysibm.sysdummy1
1
-----------
2011
db2 => select char( year(current date) ) ,char(month(current date)),char(day(cur
rent date)) from sysibm.sysdummy1
1 2 3
----------- ----------- -----------
2011 3 13
已選取 1 個記錄。
db2 => select concat( concat(trim(char(year(current date))),trim(char(month(curr
ent date))) ),trim(char(day(current date)))) from sysibm.sysdummy1
1
---------------------------------
2011313
已選取 1 個記錄。
db2 => select substr(char(year(current date)),1,4)|| case when month(current dat
e) <= 9 then '0'||substr(char(month(current date)),1,1) else substr(char(month(c
urrent date)),1,2) end || case when day(current date) <= 9 then '0'||substr(cha
r(day(current date)),1,1) else substr(char(day(current date)),1,2) end from sysi
bm.sysdummy1
1
--------
20110313
已選取 1 個記錄。
REF:
http://www.ibm.com/developerworks/data/library/techarticle/0211yip/0211yip3.html
http://www.tek-tips.com/viewthread.cfm?qid=535886&page=85