您好,登錄后才能下訂單哦!
接上貼ORACLE日期時間函數大全
日期和字符轉換函數用法(to_date,to_char)
select to_char(sysdate,'yyyy-mm-dd hh34:mi:ss') as nowTime from dual; //日期轉化為字符串
select to_char(sysdate,'yyyy') as nowYear from dual; //獲取時間的年
select to_char(sysdate,'mm') as nowMonth from dual; //獲取時間的月
select to_char(sysdate,'dd') as nowDay from dual; //獲取時間的日
select to_char(sysdate,'hh34') as nowHour from dual; //獲取時間的時
select to_char(sysdate,'mi') as nowMinute from dual; //獲取時間的分
select to_char(sysdate,'ss') as nowSecond from dual; //獲取時間的秒
求某天是星期幾
SQL> select to_char(to_date('2015-10-27','yyyy-mm-dd'),'day') from dual;
TO_CHA
------
星期二
兩個日期間的天數
SQL> select floor(sysdate - to_date('20020405','yyyymmdd')) from dual;
FLOOR(SYSDATE-TO_DATE('20020405','YYYYMMDD'))
---------------------------------------------
4949
年月日的處理
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
)
)
處理月份天數不定的辦法
select to_char(add_months(last_day(sysdate) +1, -2), 'yyyymmdd'),last_day(sysdate) from dual
原文地址;http://plat.delit.cn/thread-183-1-1.html
轉載請注明出處;
撰寫人:度量科技http://www.delit.cn
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。