반응형
oracle의 경우,
SELECT
TO_CHAR(TO_DATE('201106','YYYYMM') + LEVEL-1, 'YYYYMMDD') AS DT,
TO_CHAR(TO_DATE('201106','YYYYMM') + LEVEL-1, 'DAY') AS WEEK
FROM DUAL
CONNECT BY LEVEL <= TRUNC(TO_DATE('201106','YYYYMM')+32,'MM') - to_date('201106','YYYYMM')
DB2의 경우,
WITH DateRange(dt) AS
(
DB2의 경우,
WITH DateRange(dt) AS
(
SELECT date('2011-06-01') AS dt FROM dual
UNION ALL
SELECT (date(dt) + 1 day) AS dt FROM DateRange WHERE dt < (date('2011-07-01') - 1 day)
)
SELECT to_char(A.dt,'YYYYMMDD') as dt FROM DateRange A
SELECT to_char(A.dt,'YYYYMMDD') as dt FROM DateRange A
반응형
'데이터베이스 > DB2' 카테고리의 다른 글
DB2 관련 툴 (0) | 2012.12.31 |
---|---|
[DB2]에러코드 (0) | 2012.12.24 |
[DB2] Backup & Restore (0) | 2012.12.21 |
DB2_COMPATIBILITY_VECTOR AND DB2 EXPRESS C (0) | 2012.11.30 |
[DB2] Oracle 호환모드로 바꾸기 (0) | 2011.08.04 |