国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數(shù)據(jù)庫 > Oracle > 正文

如何在Oracle中實現(xiàn)時間相加處理?[原創(chuàng)]

2024-08-29 13:29:37
字體:
供稿:網(wǎng)友
如何在oracle中實現(xiàn)時間相加處理?
   今天由于項目的需要,老大讓我負(fù)責(zé)編寫oracle中的存儲過程。嘿,以前從來沒有接觸過,這次是個很好的學(xué)習(xí)機會,好好把握!
   但是,在使用過程中,遇到一個問題,不知道該如何實現(xiàn)時間相加功能,因為系統(tǒng)中需要用來時間相加功能。通過網(wǎng)絡(luò)找資料,但是最終一無所獲。于是,決定自己寫一個!希望可以給朋友有所幫助!


-- 名稱:add_times
-- 功能:返回d1與newtime相加以后的結(jié)果,實現(xiàn)時間的相加
-- 說明:對于newtime中的日期不予考慮
-- 日期:2004-12-07
-- 版本:1.0
-- 作者:kevin


create or replace function add_times(d1 in date,newtime in date) return date 
is
  hh   number;
  mm   number;
  ss   number;
  hours number;
  dresult  date;  
begin
  -- 下面依次取出時、分、秒
  select to_number(to_char(newtime,'hh24')) into hh from dual;
  select to_number(to_char(newtime,'mi')) into mm from dual;
  select to_number(to_char(newtime,'ss')) into ss from dual;
  -- 換算出newtime中小時總和,在一天的百分幾
  hours := (hh + (mm / 60) + (ss / 3600))/ 24;
  -- 得出時間相加后的結(jié)果
  select d1 + hours into dresult from dual;
  return(dresult);
end add_times;


-- 測試用例
-- select add_times(sysdate,to_date('2004-12-06 03:23:00','yyyy-mm-dd hh24:mi:ss')) from dual
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 淄博市| 浮梁县| 阳春市| 宝坻区| 祁阳县| 山阳县| 湖州市| 汉中市| 呼玛县| 宜川县| 韩城市| 永宁县| 瓦房店市| 浮山县| 来安县| 延长县| 宜昌市| 金湖县| 北碚区| 嵊州市| 汕尾市| 壶关县| 礼泉县| 临武县| 瓦房店市| 乐至县| 明水县| 吉安市| 神木县| 娱乐| 静海县| 抚松县| 泰顺县| 怀安县| 南川市| 明水县| 冕宁县| 定襄县| 石门县| 雅江县| 疏勒县|