Oracle to_char的時間資料格式轉換

來源:互聯網
上載者:User

Oracle to_char的一些功能記錄。

1、轉成年月日時分秒的操作;

2、轉成微妙的操作

SQL> select to_char(systimestamp, 'yyyy-mm-dd-hh24:mi:ss.ff') from dual;
 
TO_CHAR(SYSTIMESTAMP,'YYYY-MM-
------------------------------
2013-09-26-16:08:04.234000
 

注意,沒有轉成毫秒的參數格式。

如果需要轉成毫秒,這樣操作

SQL> select to_char(systimestamp, 'yyyy-mm-dd-hh24:mi:ss.ff3') from dual;
 
TO_CHAR(SYSTIMESTAMP,'YYYY-MM-
------------------------------
2013-09-26-16:12:10.640
 



3、轉成零點到目前時間的秒數

SQL> select to_char(systimestamp, 'yyyymmddhh24miss -- SSSSS') from dual;
 
TO_CHAR(SYSTIMESTAMP,'YYYYMMDD
------------------------------
20130926160938 -- 58178


SQL> select to_char(systimestamp, 'yyyy-mm-dd-hh24:mi:ss'),

  2         to_char(systimestamp, 'yyyymmddhh24miss -- SSSSS'),
  3         to_char(systimestamp, 'hh24') * 60 * 60 +
  4         to_char(systimestamp, 'mi') * 60 + to_char(systimestamp, 'ss') +
  5         to_number(to_char(systimestamp, 'ff') / 1000000.00)
  6    from dual
  7  /
 
TO_CHAR(SYSTIMESTAMP,'YYYY-MM- TO_CHAR(SYSTIMESTAMP,'YYYYMMDD TO_CHAR(SYSTIMESTAMP,'HH24')*6
------------------------------ ------------------------------ ------------------------------
2013-09-26-16:00:13            20130926160013 -- 57613                                 57613
 

其他參數如下表所示:




YYY IYI


其他語言objective-c的date格式轉換,參考

http://userguide.icu-project.org/formatparse/datetime



相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.