路人乙

心有多大,舞台就有多大。

统计

留言簿(1)

个人blog

技术网站

阅读排行榜

评论排行榜

【转载】oracle 日期常用函數 (SYSDATE、日期格式)

转自:http://www.oraclefans.cn/forum/showblog.jsp?rootid=135
SYSDATE                                                                              
--◎ 可得到目前系統的時間                                                            
                                                                                     
  ex.                                                                                
    select sysdate from dual;                                                        
                                                                                     
    sysdate                                                                          
    ----------                                                                       
    20-SEP-07                                                                        
                                                                                     
 常用之日期格式                                                                      
                                                                                     
 日期格式                 說明                                                       
 ------------------------------------------------------------------------            
 YYYY/MM/DD              -- 年/月/日                                                 
 YYYY                    -- 年(4位)                                                  
 YYY                     -- 年(3位)                                                  
 YY                      -- 年(2位)                                                  
 MM                      -- 月份                                                     
 DD                      -- 日期                                                     
 D                       -- 星期                                                     
                             -- 星期日 = 1  星期一 = 2 星期二 = 3                    
                         -- 星期三 = 4  星期四 = 5 星期五 = 6 星期六 = 7             
                                                                                     
 DDD                     -- 一年之第幾天                                             
 WW                      -- 一年之第幾週                                             
 W                       -- 一月之第幾週                                             
 YYYY/MM/DD HH24:MI:SS   -- 年/月/日 時(24小時制):分:秒                              
 YYYY/MM/DD HH:MI:SS     -- 年/月/日 時(非24小時制):分:秒                            
 J                       -- Julian day,Bc 4712/01/01 為1                            
 RR/MM/DD                -- 公元2000問題                                             
                -- 00-49 = 下世紀;50-99 = 本世紀                        
 ex.                                                                                  
 
select to_char(sysdate,'YYYY/MM/DD'FROM DUAL;             -- 2007/09/20            
 select to_char(sysdate,'YYYY'FROM DUAL;                   -- 2007                  
 select to_char(sysdate,'YYY'FROM DUAL;                    -- 007                   
 select to_char(sysdate,'YY'FROM DUAL;                     -- 07                    
 select to_char(sysdate,'MM'FROM DUAL;                     -- 09                    
 select to_char(sysdate,'DD'FROM DUAL;                     -- 20                    
 select to_char(sysdate,'D'FROM DUAL;                      -- 5                     
 select to_char(sysdate,'DDD'FROM DUAL;                    -- 263                   
 select to_char(sysdate,'WW'FROM DUAL;                     -- 38                    
 select to_char(sysdate,'W'FROM DUAL;                      -- 3                     
 select to_char(sysdate,'YYYY/MM/DD HH24:MI:SS'FROM DUAL;  -- 2007/09/20 15:24:13   
 select to_char(sysdate,'YYYY/MM/DD HH:MI:SS'FROM DUAL;    -- 2007/09/20 03:25:23   
 select to_char(sysdate,'J'FROM DUAL;                      -- 2454364               
 select to_char(sysdate,'RR/MM/DD'FROM DUAL;               -- 07/09/20     
        

posted on 2008-09-18 20:32 上帝也犯困 阅读(2816) 评论(0)  编辑  收藏 所属分类: 数据库


只有注册用户登录后才能发表评论。


网站导航: