oracle构造时间

一、构造年:

(SELECT 2007+LEVEL-1 year FROM DUAL CONNECT BY LEVEL<2013-2007+2);

year

2007
2008
2009
2010
2011
2012
2013


二、构造月:

SELECT TO_CHAR(ADD_MONTHS(DATE'2007-07-01',LEVEL-1),'YYYY-MM') MONTH FROM DUAL CONNECT BY LEVEL<(months_between(DATE'2007-12-01',DATE'2007-07-01')+2);

month

2007-07
2007-08
2007-09
2007-10
2007-11
2007-12


三、构造天:

SELECT DATE'2007-07-01'+LEVEL-1 DAY FROM DUAL CONNECT BY LEVEL<(DATE'2007-07-07' - DATE'2007-07-01'+2);

DAY

7/1/2007
7/2/2007
7/3/2007
7/4/2007
7/5/2007
7/6/2007
7/7/2007



你可能感兴趣的:(ORACLE)