oracle得到两年的日期

SELECT ROWNUM,'1' AS FLAG
             ,(TO_DATE(TO_CHAR(DATE'2015-12-31','YYYY')||'-01-01','YYYY-MM-DD')+ ROWNUM - 1) AS DATE_DT
             ,DATE'2015-12-31' AS DATA_DATE
             ,SUBSTR(TO_CHAR((TO_DATE(TO_CHAR(DATE'2015-12-31','YYYY')||'-01-01','YYYY-MM-DD')+ ROWNUM - 1),'YYYY-MM-DD'),0,4) AS YEAR_0
FROM TOTAL  
WHERE ROWNUM <= (TO_DATE(TO_NUMBER(TO_CHAR(DATE'2015-12-31','YYYY') )+ 1 || '-12-31','YYYY-MM-DD')-
                                TO_DATE(TO_CHAR(DATE'2015-12-31','YYYY') || '-01-01','YYYY-MM-DD')+1)

posted on 2016-04-26 17:02  vbvb520  阅读(299)  评论(0编辑  收藏  举报

导航