Oracle時(shí)間實(shí)際應(yīng)用代碼的示例
以下的文章主要是通過相關(guān)的代碼的方式來引出Oracle時(shí)間的實(shí)際應(yīng)用,前兩天我在相關(guān)的網(wǎng)站看到關(guān)于Oracle時(shí)間的實(shí)際應(yīng)用的資料,如果你對(duì)其相關(guān)的實(shí)際操作有興趣的話,你就可以對(duì)以下的文章點(diǎn)擊觀看了。
- select to_char(sysdate,''hh:mi:ss'') TIME from all_objects
注意:第一條記錄的TIME 與最后一行是一樣的
可以建立一個(gè)函數(shù)來處理這個(gè)問題
- create or replace function sys_date return date is
- begin
- return sysdate;
- end;
- select to_char(sys_date,''hh:mi:ss'') from all_objects;
Oracle時(shí)間的應(yīng)用中獲得小時(shí)數(shù)
- SELECT EXTRACT(HOUR FROM TIMESTAMP ''2001-02-16 2:38:40'') from offer
- SQL> select sysdate ,to_char(sysdate,''hh'') from dual;
- SYSDATE TO_CHAR(SYSDATE,''HH'')
- 2003-10-13 19:35:21 07
- SQL> select sysdate ,to_char(sysdate,''hh24'') from dual;
- SYSDATE TO_CHAR(SYSDATE,''HH24'')
- 2003-10-13 19:35:21 19
獲取年月日與此類似
Oracle時(shí)間的應(yīng)用中年月日的處理
- select older_date,
- newer_date,
- years,
- months,
- abs(
- trunc(
- newer_date-
- add_months( older_date,years*12+months )
- )
- ) days
- from ( select
- trunc(months_between( newer_date, older_date )/12) YEARS,
- mod(trunc(months_between( newer_date, older_date )),
- 12 ) MONTHS,
- newer_date,
- older_date
- from ( select hiredate older_date,
- add_months(hiredate,rownum)+rownum newer_date
- from emp )
- )
以上的相關(guān)內(nèi)容就是對(duì)Oracle時(shí)間的應(yīng)用的相關(guān)項(xiàng)目的介紹,望你能有所收獲。
文章出自: http://www.programbbs.com/doc/class10-3.htm
【編輯推薦】