일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- sencha touch
- Android
- jQuery
- dock
- Ajax
- Spring
- JSON
- Google Map
- 가우스
- swingx
- MFC
- MySQL
- oracle
- Struts
- Eclipse
- JDOM
- iBATIS
- node.js
- PHP
- ibsheet
- 선택적조인
- jsr 296
- 전자정부프레임워크
- GPS
- rowspan
- WebLogic
- appspresso
- tomcat
- PLSQL
- phonegap
Archives
- Today
- Total
Where The Streets Have No Name
해당월의 시작일부터 말일까지 날짜출력 본문
방법1)
SELECT x.date_val FROM (
select TRUNC(to_date('20060701'),'YYYY')+ROWNUM -1 as date_val,
TO_CHAR(TRUNC(to_date('20060701'),'YYYY')+ROWNUM -1,'YYYYMM') as year_month,
TO_CHAR(TRUNC(to_date('200607010'),'YYYY')+ROWNUM -1,'DD') as day,
ROWNUM
FROM all_objects
WHERE TRUNC(to_date('20060701'),'YYYY')+ROWNUM -1 < ADD_MONTHS(TRUNC(to_date('20060701'),'YYYY'),12)
) x
where year_month = to_number(to_char(to_date('20060701'),'YYYYMM'));
방법2)
create or replace type tabDate as table of date;
create or replace function dates_in_month (p_month date)
return tabDate pipelined is
begin
for i in 0 .. to_number(add_months(p_month,1)-p_month-1) loop
pipe row (p_month+i);
end loop;
return;
end;
/
select *
from table (dates_in_month(to_date('01-jan-2002','DD-mon-YYYY')));
SELECT x.date_val FROM (
select TRUNC(to_date('20060701'),'YYYY')+ROWNUM -1 as date_val,
TO_CHAR(TRUNC(to_date('20060701'),'YYYY')+ROWNUM -1,'YYYYMM') as year_month,
TO_CHAR(TRUNC(to_date('200607010'),'YYYY')+ROWNUM -1,'DD') as day,
ROWNUM
FROM all_objects
WHERE TRUNC(to_date('20060701'),'YYYY')+ROWNUM -1 < ADD_MONTHS(TRUNC(to_date('20060701'),'YYYY'),12)
) x
where year_month = to_number(to_char(to_date('20060701'),'YYYYMM'));
방법2)
create or replace type tabDate as table of date;
create or replace function dates_in_month (p_month date)
return tabDate pipelined is
begin
for i in 0 .. to_number(add_months(p_month,1)-p_month-1) loop
pipe row (p_month+i);
end loop;
return;
end;
/
select *
from table (dates_in_month(to_date('01-jan-2002','DD-mon-YYYY')));