日期:2014-05-16  浏览次数:20873 次

帮我取下一年的所有日期,先谢了
如何取一年内的所月日期,如:
2012-01-01
2012-01-02
...
2012-12-31


------解决方案--------------------
SQL code

select to_char(to_date(to_char(sysdate, 'yyyy')|| '-01-01', 'yyyy-mm-dd')+rownum-1, 'yyyy-mm-dd') from dual connect by rownum< to_date(to_char(sysdate, 'yyyy')+1|| '-01-01', 'yyyy-mm-dd')-to_date(to_char(sysdate, 'yyyy')|| '-01-01', 'yyyy-mm-dd')+1;

------解决方案--------------------
SQL code

SQL> select to_char(to_date(to_char(sysdate, 'yyyy')|| '-01-01', 'yyyy-mm-dd')+rownum-1, 'yyyy-mm-dd') from dual connect by rownum< to_date(to_char(sysdate, 'yyyy')+1|| '-01-01', 'yyyy-mm-dd')-to_date(to_char(sysdate, 'yyyy')|| '-01-01', 'yyyy-mm-dd')+1;

TO_CHAR(TO_DATE(TO_C                                                            
--------------------                                                            
2012-01-01                                                                      
2012-01-02                                                                      
...                                                                 
2012-12-04                                                                      
2012-12-05                                                                      
2012-12-06                                                                      
2012-12-07                                                                      
2012-12-08                                                                      
2012-12-09                                                                      
2012-12-10                                                                      
2012-12-11                                                                      
2012-12-12                                                                      
2012-12-13                                                                      
2012-12-14                                                                      
2012-12-15                                                                      
2012-12-16                                                                      
2012-12-17                                                                      
2012-12-18                                                                      
2012-12-19                                                                      
2012-12-20                                                                      
2012-12-21                                                                      
2012-12-22                                                                      
2012-12-23                                                                      
2012-12-24                                                                      
2012-12-25                                                                      
2012-12-26                                                                      
2012-12-27                                                                      
2012-12-28                                                                      
2012-12-29                                                                      
2012-12-30                                                                      
2012-12-31                                                                      

已选择366行。